Jump to content

Two forms in one page possible?


Guest sahil

Recommended Posts

if i want to use two forms in one asp.net page .how could i do this.if i add attribute runat="server" in two form tags on same page ...it gives error as only one form can have runat="server" attribute

Link to comment
Share on other sites

  • 3 weeks later...

Use only one form but have 2 submit buttons, create OnClick functions for each button. Each function can process the parts of the form you need.<body><script runat="server" language="c#">private void Page_Load(){}private void Button1_Click(object sender, System.EventArgs e){...do something}private void Button2_Click(object sender, System.EventArgs e){...do something}</script>...<form runat="server">...form fields, etc<input type="button" value="Button 1" id="Button1" runat="server" OnServerClick="Button1_Click" /><input type="button" value="Button 2" id="Button2" runat="server" OnServerClick="Button2_Click" /></form></body>

Link to comment
Share on other sites

if i want to use two forms in one asp.net page .how could i do this.if i add attribute runat="server" in two  form tags on same page ...it gives  error as only one form can have runat="server" attribute

you can do this. use solution explorer->project->add pageto swith to the pagewrite code such as response.redirect("pagename.aspx")
Link to comment
Share on other sites

that is still only using one form per page and the same results can be acheived in 1 form and on only 1 page, that is why there are different event handlers.What is the specific reason you think you need to use 2 forms????Please post your needs and I can explain how to get it done.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...