Multi form in one page

I would like to know how can I add more then 1 form on the same page. I need to have a quick search, and a login form.
but when I add both, I get an error saying that I cannot have more then one form.
LVL 1
EnnioAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
BurntSkyConnect With a Mentor Commented:
You can't have more than one Form in ASP.NET applications (one of the many changes from ASP 3).  But this doesn't mean you can't do what you're asking.

Attach an event handler to your "search" and "login" button's click events.

private void Page_Load(object sender, System.EventArgs e)
{
      this.btnSearch.Click += new EventHandler(btnSearch_Click);
      this.btnLogin.Click += new EventHandler(btnLogin_Click);
}

private void btnSearch_Click(object sender, EventArgs e)
{
      // Code to handle search here
}

private void btnLogin_Click(object sender, EventArgs e)
{
      // Code to handle login here
}
0
 
EnnioAuthor Commented:
Ok, and I should have both my search and my login inside the same <form>??
0
 
BurntSkyCommented:
Yes.  In ASP.NET applications all web controls must be contained within a single <form /> tag.  Be sure the tag contains the runat=server attribute.  It should look like this:

<form id="Form1" method="post" runat="server"></form>

If you're new to ASP.NET here's a couple resources you should check out:

http://aspnet.4guysfromrolla.com/
http://www.asp.net/Tutorials/quickstart.aspx
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpqstart/html/cpsmpASPNETQuickStart.asp
http://msdn.microsoft.com/asp.net/gettingstarted/
0
All Courses

From novice to tech pro — start learning today.