query-stringhttpcontextautopostbackpostbackurl

add querystring to a postbackurl property of asp:button


I've got a textbox and a button on a form on default.aspx and in my DownloadHandler.ashx I am getting the value I need from HttpContext.Request.Form("txtURI"):

            <asp:TextBox ID="txtURI"
                        AutoPostBack="true"
                        runat="server"></asp:TextBox>
            <asp:Button ID="DownloadButton"
                        PostBackUrl="~/DownloadHandler.ashx" 
                        runat="server" 
                        Text="Download"/>

I would like to change it so that the value typed into the textbox gets passed to the DownloadHandler.ashx as a querystring (instead of picking it out of the Request.Form).

What is the best way to accomplish that?


Solution

  • I think you answered your own question. I believe you're going to have to pick it up on the request and redirect.

    Actually, the more I think about it. You could add a OnClientClick, calling a javascript function which would grab the value from the field and do the submit there. I would just do it serverside however.