[thelist] .NET - using variable as form field value

Anthony Baratta anthony at baratta.com
Wed Aug 1 17:02:21 CDT 2007

Do you have page one posting to page 2?? Or is the form posting to itself?

Basically the receiving form element will have an attribute called runat="server" attached to it and an "id" attribute.

so you end up like this:

<input type="hidden" name="EmpID2" id="EmpID2" runat="server" />

Then in your code just do this:

EmpID2.Value = HttpContext.Current.Response.Form["EmpID"].ToString();

-----Original message-----
From: "Joel D Canfield" joel at streamliine.com
Date: Wed, 01 Aug 2007 14:04:26 -0700
To: thelist at lists.evolt.org
Subject: [thelist] .NET - using variable as form field value

> really *really* new to .NET, so this is probably deadly simple:
> how do I get the value of the requesting form's field 'EmpID' and insert
> it into a hidden form field in the new page?
> in classic ASP, I'd do this:
>     <%
>       Dim intEmpID
>       intEmpID = Request.Form("EmpID")
>     %>
>     <input type="hidden" name="EmpID2" id="EmpID2" value="<%=intEmpID%>"
> />
> grrr . . . I hate starting over again
> thanks
> joel

More information about the thelist mailing list