Request.Querystring "undefined"
-
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
-
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
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.
-
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
[Message Deleted]
-
[Message Deleted]
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 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.
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.
-
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.
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
-
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
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.
-
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.
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
-
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
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> -
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>YOU ARE THE BEST!!!! It works perfectly, thanks a lot!!!
Time to come clean... Vive y deja vivir / Live and let live Javier
-
YOU ARE THE BEST!!!! It works perfectly, thanks a lot!!!
Time to come clean... Vive y deja vivir / Live and let live Javier
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> -
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
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.
-
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>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.
-
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.
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> -
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>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.
-
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
just: <pre> onclick="Download(document.getElementById('txtFile').value)" </pre>
-
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.
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 atextbox
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>