Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Request.Querystring "undefined"

Request.Querystring "undefined"

Scheduled Pinned Locked Moved ASP.NET
helpjavascriptsysadminalgorithmstools
17 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    garfield185
    wrote on last edited by
    #1

    Hi all. I'm programming an site, where I create a file on server side, an I need it to be downloaded to client after it finishes. At this moment, I am coding it step by step: - A button to create the file - Another button to download it, once it is created. I can create the file correctly, but when I try to download it this is what happens: There is an asp:textbox where I have the name of the file (I get the path with Request.ServerVariables("APPL_PHYSICAL_PATH") so that's OK) Then I press the input type=button control I have, and call a javascript function like this:

    <script type="text/javascript">
    function Download(nom_fich)
    {
    window.open("Downloadfile.aspx?ar=" + nom_fich,"Download","width=10,height=10,resizable=yes;top=200,left=150,menubar=no,toolbar=no,status=no,location=no");
    }
    </script>

    Once I am on the Page_Load event of the Downloadfile.aspx page, I get the parameter from "ar" and I just get "undefined". I don't know if the problem is when taking the file name from the asp:textbox control, because when I get it from an input control, it is OK... Please, help me, I have been searching for an answer for so long, and I can't stand it anymore. Thanks in advance. PS: This is the input button I use:

    <input id="Bt_Descarga" class="" visible="TRUE" style="width: 100px" type="button" value="Download" onclick="Download(txtFile.text)" />

    And this is the asp:textbox control I need to take the filename from.

    <asp:Textbox ID="txtFichero" runat="server" CssClass="cuerpopar" Width="100%"></asp:Textbox>

    Time to come clean...

    Vive y deja vivir / Live and let live

    Javier

    C I A 3 Replies Last reply
    0
    • G garfield185

      Hi all. I'm programming an site, where I create a file on server side, an I need it to be downloaded to client after it finishes. At this moment, I am coding it step by step: - A button to create the file - Another button to download it, once it is created. I can create the file correctly, but when I try to download it this is what happens: There is an asp:textbox where I have the name of the file (I get the path with Request.ServerVariables("APPL_PHYSICAL_PATH") so that's OK) Then I press the input type=button control I have, and call a javascript function like this:

      <script type="text/javascript">
      function Download(nom_fich)
      {
      window.open("Downloadfile.aspx?ar=" + nom_fich,"Download","width=10,height=10,resizable=yes;top=200,left=150,menubar=no,toolbar=no,status=no,location=no");
      }
      </script>

      Once I am on the Page_Load event of the Downloadfile.aspx page, I get the parameter from "ar" and I just get "undefined". I don't know if the problem is when taking the file name from the asp:textbox control, because when I get it from an input control, it is OK... Please, help me, I have been searching for an answer for so long, and I can't stand it anymore. Thanks in advance. PS: This is the input button I use:

      <input id="Bt_Descarga" class="" visible="TRUE" style="width: 100px" type="button" value="Download" onclick="Download(txtFile.text)" />

      And this is the asp:textbox control I need to take the filename from.

      <asp:Textbox ID="txtFichero" runat="server" CssClass="cuerpopar" Width="100%"></asp:Textbox>

      Time to come clean...

      Vive y deja vivir / Live and let live

      Javier

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Have you looked at the URL at all ?

      garfield185 wrote:

      onclick="Download(txtFile.text)" />

      This quite obviously does not work. You need to get the client side id of the control, then use document.getElementById to look up the control, then get it's actual text. You can use the alert function to debug your code, if you do that now, you'll find that it's null, which is why you're getting the result you are.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      G 1 Reply Last reply
      0
      • G garfield185

        Hi all. I'm programming an site, where I create a file on server side, an I need it to be downloaded to client after it finishes. At this moment, I am coding it step by step: - A button to create the file - Another button to download it, once it is created. I can create the file correctly, but when I try to download it this is what happens: There is an asp:textbox where I have the name of the file (I get the path with Request.ServerVariables("APPL_PHYSICAL_PATH") so that's OK) Then I press the input type=button control I have, and call a javascript function like this:

        <script type="text/javascript">
        function Download(nom_fich)
        {
        window.open("Downloadfile.aspx?ar=" + nom_fich,"Download","width=10,height=10,resizable=yes;top=200,left=150,menubar=no,toolbar=no,status=no,location=no");
        }
        </script>

        Once I am on the Page_Load event of the Downloadfile.aspx page, I get the parameter from "ar" and I just get "undefined". I don't know if the problem is when taking the file name from the asp:textbox control, because when I get it from an input control, it is OK... Please, help me, I have been searching for an answer for so long, and I can't stand it anymore. Thanks in advance. PS: This is the input button I use:

        <input id="Bt_Descarga" class="" visible="TRUE" style="width: 100px" type="button" value="Download" onclick="Download(txtFile.text)" />

        And this is the asp:textbox control I need to take the filename from.

        <asp:Textbox ID="txtFichero" runat="server" CssClass="cuerpopar" Width="100%"></asp:Textbox>

        Time to come clean...

        Vive y deja vivir / Live and let live

        Javier

        I Offline
        I Offline
        Imran Khan Pathan
        wrote on last edited by
        #3

        [Message Deleted]

        C 1 Reply Last reply
        0
        • I Imran Khan Pathan

          [Message Deleted]

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          I think you'll find that this is utterly wrong.

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          I 1 Reply Last reply
          0
          • C Christian Graus

            I think you'll find that this is utterly wrong.

            Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

            I Offline
            I Offline
            Imran Khan Pathan
            wrote on last edited by
            #5

            Yes. I know so I have deleted that post after posting it. Thanks

            please don't forget to vote on the post that helped you.

            1 Reply Last reply
            0
            • C Christian Graus

              Have you looked at the URL at all ?

              garfield185 wrote:

              onclick="Download(txtFile.text)" />

              This quite obviously does not work. You need to get the client side id of the control, then use document.getElementById to look up the control, then get it's actual text. You can use the alert function to debug your code, if you do that now, you'll find that it's null, which is why you're getting the result you are.

              Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

              G Offline
              G Offline
              garfield185
              wrote on last edited by
              #6

              OK, I have no idea what you are talking about... Sorry!!! Could you please write a clue? :laugh: :laugh:

              Time to come clean... Vive y deja vivir / Live and let live Javier

              C 1 Reply Last reply
              0
              • G garfield185

                OK, I have no idea what you are talking about... Sorry!!! Could you please write a clue? :laugh: :laugh:

                Time to come clean... Vive y deja vivir / Live and let live Javier

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #7

                txtFile.Text is not valid javascript. So, it's not working. On the server side, you can get the client side id of your control ( which is not even called txtFile, from what you posted ), and then you can use document.getElementById(clientId) ( where clientId contains that id you got from the server ), to get a reference to the actual control. Then you can get the text of the control ( I think .value is what you want, it's sure not .text ).

                Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                G 1 Reply Last reply
                0
                • C Christian Graus

                  txtFile.Text is not valid javascript. So, it's not working. On the server side, you can get the client side id of your control ( which is not even called txtFile, from what you posted ), and then you can use document.getElementById(clientId) ( where clientId contains that id you got from the server ), to get a reference to the actual control. Then you can get the text of the control ( I think .value is what you want, it's sure not .text ).

                  Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                  G Offline
                  G Offline
                  garfield185
                  wrote on last edited by
                  #8

                  Do you know any web page with an example of all this you are writing?

                  Time to come clean... Vive y deja vivir / Live and let live Javier

                  C S 2 Replies Last reply
                  0
                  • G garfield185

                    Hi all. I'm programming an site, where I create a file on server side, an I need it to be downloaded to client after it finishes. At this moment, I am coding it step by step: - A button to create the file - Another button to download it, once it is created. I can create the file correctly, but when I try to download it this is what happens: There is an asp:textbox where I have the name of the file (I get the path with Request.ServerVariables("APPL_PHYSICAL_PATH") so that's OK) Then I press the input type=button control I have, and call a javascript function like this:

                    <script type="text/javascript">
                    function Download(nom_fich)
                    {
                    window.open("Downloadfile.aspx?ar=" + nom_fich,"Download","width=10,height=10,resizable=yes;top=200,left=150,menubar=no,toolbar=no,status=no,location=no");
                    }
                    </script>

                    Once I am on the Page_Load event of the Downloadfile.aspx page, I get the parameter from "ar" and I just get "undefined". I don't know if the problem is when taking the file name from the asp:textbox control, because when I get it from an input control, it is OK... Please, help me, I have been searching for an answer for so long, and I can't stand it anymore. Thanks in advance. PS: This is the input button I use:

                    <input id="Bt_Descarga" class="" visible="TRUE" style="width: 100px" type="button" value="Download" onclick="Download(txtFile.text)" />

                    And this is the asp:textbox control I need to take the filename from.

                    <asp:Textbox ID="txtFichero" runat="server" CssClass="cuerpopar" Width="100%"></asp:Textbox>

                    Time to come clean...

                    Vive y deja vivir / Live and let live

                    Javier

                    A Offline
                    A Offline
                    Abhishek Sur
                    wrote on last edited by
                    #9

                    garfield185 wrote:

                    Why dont you pass :

                    onclick = "javascript:Download(document.getElementById('<%=txtFile.ClientId%>').value);"

                    I hope this would work perfectly. If not let me know. :rose:

                    Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                    My Latest Articles-->** Microsoft Bing MAP using Javascript
                    CLR objects in SQL Server 2005
                    Uncommon C# Keywords
                    /xml>

                    G C 2 Replies Last reply
                    0
                    • A Abhishek Sur

                      garfield185 wrote:

                      Why dont you pass :

                      onclick = "javascript:Download(document.getElementById('<%=txtFile.ClientId%>').value);"

                      I hope this would work perfectly. If not let me know. :rose:

                      Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                      My Latest Articles-->** Microsoft Bing MAP using Javascript
                      CLR objects in SQL Server 2005
                      Uncommon C# Keywords
                      /xml>

                      G Offline
                      G Offline
                      garfield185
                      wrote on last edited by
                      #10

                      YOU ARE THE BEST!!!! It works perfectly, thanks a lot!!!

                      Time to come clean... Vive y deja vivir / Live and let live Javier

                      A 1 Reply Last reply
                      0
                      • G garfield185

                        YOU ARE THE BEST!!!! It works perfectly, thanks a lot!!!

                        Time to come clean... Vive y deja vivir / Live and let live Javier

                        A Offline
                        A Offline
                        Abhishek Sur
                        wrote on last edited by
                        #11

                        you are most welcome my friend.. Cheers. :rose::thumbsup:

                        Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                        My Latest Articles-->** Microsoft Bing MAP using Javascript
                        CLR objects in SQL Server 2005
                        Uncommon C# Keywords
                        /xml>

                        1 Reply Last reply
                        0
                        • G garfield185

                          Do you know any web page with an example of all this you are writing?

                          Time to come clean... Vive y deja vivir / Live and let live Javier

                          C Offline
                          C Offline
                          Christian Graus
                          wrote on last edited by
                          #12

                          Well, if I were to google getElementById, I know I'd easily find that part of it. As for the rest, just use RegisterClientScript to emit javascript from the server that creates a variable which contains the client side id of your textbox, using the ClientID property.

                          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                          1 Reply Last reply
                          0
                          • A Abhishek Sur

                            garfield185 wrote:

                            Why dont you pass :

                            onclick = "javascript:Download(document.getElementById('<%=txtFile.ClientId%>').value);"

                            I hope this would work perfectly. If not let me know. :rose:

                            Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                            My Latest Articles-->** Microsoft Bing MAP using Javascript
                            CLR objects in SQL Server 2005
                            Uncommon C# Keywords
                            /xml>

                            C Offline
                            C Offline
                            Christian Graus
                            wrote on last edited by
                            #13

                            Interesting, when I've tried to do that directly, it's not done the translation to emit the client id, it's appeared in my javascript verbatim. That's why I advocate storing the client side id in a variable.

                            Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                            A 1 Reply Last reply
                            0
                            • C Christian Graus

                              Interesting, when I've tried to do that directly, it's not done the translation to emit the client id, it's appeared in my javascript verbatim. That's why I advocate storing the client side id in a variable.

                              Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                              A Offline
                              A Offline
                              Abhishek Sur
                              wrote on last edited by
                              #14

                              Yes... Its the same thing. I dont know why he didnt understand. :)

                              Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                              My Latest Articles-->** Microsoft Bing MAP using Javascript
                              CLR objects in SQL Server 2005
                              Uncommon C# Keywords
                              /xml>

                              C 1 Reply Last reply
                              0
                              • A Abhishek Sur

                                Yes... Its the same thing. I dont know why he didnt understand. :)

                                Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                                My Latest Articles-->** Microsoft Bing MAP using Javascript
                                CLR objects in SQL Server 2005
                                Uncommon C# Keywords
                                /xml>

                                C Offline
                                C Offline
                                Christian Graus
                                wrote on last edited by
                                #15

                                Well, your solution was so simple that you could give him one line of code. I do tend not to give code, because it makes people think and understand, but in this case, my experience made me feel that may not actually work. Perhaps I've just done it in a specific context where it wouldn't process the server tags ?

                                Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                                A 1 Reply Last reply
                                0
                                • G garfield185

                                  Do you know any web page with an example of all this you are writing?

                                  Time to come clean... Vive y deja vivir / Live and let live Javier

                                  S Offline
                                  S Offline
                                  sohighthesky
                                  wrote on last edited by
                                  #16

                                  just: <pre> onclick="Download(document.getElementById('txtFile').value)" </pre>

                                  1 Reply Last reply
                                  0
                                  • C Christian Graus

                                    Well, your solution was so simple that you could give him one line of code. I do tend not to give code, because it makes people think and understand, but in this case, my experience made me feel that may not actually work. Perhaps I've just done it in a specific context where it wouldn't process the server tags ?

                                    Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                                    A Offline
                                    A Offline
                                    Abhishek Sur
                                    wrote on last edited by
                                    #17

                                    Might be. Can you show me where it is not working. I think there must be problem of mixing up server tags within server side controls. For example If you write : <asp:TextBox ID="txt" Text="<%= this.somevariable %>" runat="server" /> You will actually end up with a textbox which has value <%=this.somevariable%> rather than the value of the variable. on the other hand if you write : <input type="text" id="txt" value="<%= this.somevariable %>" /> It will properly show the value of the variable in the textbox. In your case this might be the issue. :)

                                    Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                                    My Latest Articles-->** Microsoft Bing MAP using Javascript
                                    CLR objects in SQL Server 2005
                                    Uncommon C# Keywords
                                    /xml>

                                    1 Reply Last reply
                                    0
                                    Reply
                                    • Reply as topic
                                    Log in to reply
                                    • Oldest to Newest
                                    • Newest to Oldest
                                    • Most Votes


                                    • Login

                                    • Don't have an account? Register

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular
                                    • World
                                    • Users
                                    • Groups