How do you pass an aspx form value to aspx.cs variable. When I am on page 1 and select item 1, I'd like the value of PROC1 to be sent to the next page. I don't know how to accept it.
aspx form (page1.aspx)
<select>
<option value="" disabled="disabled" selected="selected">Please select a name</option>
<option value="PROC1">item 1</option>
<option value="PROC2">item 2</option>
</select>
<input type="submit" value="Submit" />
receiving c# class (page2.aspx)
protected void Page_Load(object sender, EventArgs e)
{
// I want to know how to capture the value of PROC1
// so I can use it as a variable on this new page
}
First you need to give your form element a name
attribute. This is the "key" in the key/value pairs that forms send to the server:
<select name="someSelect">
Then when this form posts to a page, you can access the form values in the Request
object on that page:
var selectedValue = Request.Form["someSelect"];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.