Reputation: 13551
I have a static page that contains a form.
<form METHOD="post" ACTION="...">
<input type="submit" value="Verzenden" />
</form>
When the submit button is clicked, I want the form fields to be sent to an ASP.NET page, in which I receive the form fields and do something with them (like sending a mail).
I was thinking to do something like this:
<form METHOD="post" ACTION="http://localhost:3384/mail.aspx">
<input type="submit" value="Verzenden" />
</form>
But how can I receive this data in the mail.aspx code behind?
Thanks
Upvotes: 0
Views: 2449
Reputation: 62301
<form action="Default.aspx" method="post">
<input type="text" name="fullname">
<select name="color">
<option value="Red">Red $10.00</option>
<option value="Blue">Blue $8.00</option>
<option value="Green">Green $12.00</option>
</select>
<select name="size">
<option value="Small">Small</option>
<option value="Large">Large</option>
</select>
<input type="submit" value="Verzenden" />
</form>
protected void Page_Load(object sender, EventArgs e)
{
FullNameLabel.Text = Request.Form["fullname"];
ColorLabel.Text = Request.Form["color"];
SizeLabel.Text = Request.Form["size"];
}
Upvotes: 1
Reputation: 40160
Just use the Request.Form
collection:
string verz = Request.Form["Verzenden"];
etc...
Doing this in Page_Load
is easiest. It's probably best to avoid having a typical postback form on that page, just to keep things simple; otherwise, you have to test for IsPostBack
to make sure you should read the Form
values.
Upvotes: 1