user1477388
user1477388

Reputation: 21430

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.

Upvotes: 4

Views: 38809

Answers (1)

David W
David W

Reputation: 10184

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"]

Upvotes: 12

Related Questions