Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET HiddenField Value Setting

I have googled this, but can't figure out how to set the value of my hidden field. I have the following code:

<asp:HiddenField id="fileId" runat="server" value="<%# Response.Write(Request.QueryString["fileID"]) %>" />

I am just trying to make the value = the value of fileID in the query string.

Thanks for your help.

like image 797
user1477388 Avatar asked Dec 26 '22 09:12

user1477388


1 Answers

Try:

<asp:HiddenField id="fileId" runat="server" value='<%= Request.QueryString["fileID"] %>' />

Believe the "=" operator implies the Response.Write for you.

Just for the sake of completeness, you could set it in the codebehind as well, eg

fileId.Value = Request.QueryString["fileID"]
like image 169
David W Avatar answered Mar 13 '23 00:03

David W