0

In my project I want to run 2 forms in one webpage which is master page one is for contact us and one is for signup user. but multiple server side forms are not allowed. is there any solution for fix it?

Akshay Khade
  • 57
  • 1
  • 11
  • see this, if this can help.. http://stackoverflow.com/questions/8712398/multiple-forms-or-multiple-submits-in-a-page – Naveed Butt Aug 25 '14 at 08:00

3 Answers3

0

You can use postback ability of Asp.net Webforms. You should create one button for singup and another one for contact. You can catch event in server side and you do what want to do.

Dreamcatcher
  • 798
  • 13
  • 31
0

You can create regular client side forms created using HTML in the master page, and use the Request.Form to read the posted data. For this to work, all the input elements must have a name, and you can read them using Request.Form["ElementName"].

Take into account that forms cannot be nested.

So, your master page needs to llok like this

...
<body>
   <form id="form1" runat="server">
   </form>
   <form id="contact" action="Contact.aspx" method="post">
       <input type="text" name="Message"/>
       <input type="submit" value="Contact us!"/>
   </form>
</body>

The first <form> is the regular ASP.NET server side form, which supports server side components

The second <form> is a custom HTML form. It doesn't have the runat="server" attribute, and it's outside the server side <form>.

The second form action points to a .aspx page. In its page load event you can use the Request.Form["Name"] to acces the name of the contact form. Note that you also need to include a submit button to send the data to the server, and a method="post" to specify the method to send the page.

This is resorting to "basic" HTML controls, so there is no View State, and the posted values will be lost if they're not reset in the server. I.e. if the form is posted, and there's an error, the previously posted values will be lost when rendering the page again.

If you want to make it more sophisticated you can use Javascript and, optionally AJAX. But that's a more complex solution. See this for an example.

Community
  • 1
  • 1
JotaBe
  • 38,030
  • 8
  • 98
  • 117
0

ASP.NET Forms only supports one form. You could use an iFrame and render your second page (second form) inside of the iFrame.

Here is an interesting post about placing some page content after the tag. This may be helpful to you.

http://forums.asp.net/t/1611822.aspx?Dynamically+adding+content+to+page+outside+of+the+aspnet+form+from+within+a+UC

Elim Garak
  • 1,728
  • 1
  • 16
  • 21