4

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.

user1477388
  • 20,790
  • 32
  • 144
  • 264

1 Answers1

12

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"]
David W
  • 10,062
  • 34
  • 60
  • I didn't use the `=` operator, but I did change from my double quotes to using single quotes and it works... Didn't realize I couldn't use single quotes here. Thanks for your answer. – user1477388 Feb 18 '13 at 16:01
  • Your photo is making me so hungry! It's lunch time where I am – user1477388 Feb 18 '13 at 16:03