By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,964 Members | 1,318 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,964 IT Pros & Developers. It's quick & easy.

How to Handle Multiple Forms on a Page

P: n/a
Hi,

I am very new beginner to ASP.NET, but I inherited this ASP.NET
project from a person who left our company. So I hope that my problem
is fairly simple to solve.

Here is the background to the problem: I am working on the "Contact
Us" page for an e-commerce website. This page consists of the main
section of the page (Contact Us fields like First Name, Last Name,
etc.) and navigation sections (Navigation bar, Search textbox,
drop-down box & button, Subscribe now textbox & button). The side,
top, bottom navigation and Search fields have been put into separate
controls.

On the aspx page, I have the following defined:
<%@ Page language="c#" Codebehind="Contact.aspx.cs"
AutoEventWireup="false" Inherits="AOpenCenter.Contact.Contact" %>
<%@ Register TagPrefix="AOC" TagName="Footer"
Src="/controls/Footer.ascx" %>
<%@ Register TagPrefix="AOC" TagName="SearchBox"
Src="/controls/SearchBox.ascx" %>
<%@ Register TagPrefix="AOC" TagName="LeftNav"
Src="/controls/LeftNav.ascx" %>
<%@ Register TagPrefix="AOC" TagName="TopNav"
Src="/controls/TopNav.ascx" %>
<%@ Register TagPrefix="AOC" TagName="Header"
Src="/controls/Header.ascx" %>
<%@ Register TagPrefix="AOC" TagName="HeadTag"
Src="/controls/HeadTag.ascx" %>

I have a button that I want to submit my contact us fields.
Here is the button definition:
<asp:ImageButton ID="ContactUsButton" onClick="OnClick_Submit"
imageURL="/images/btnSubmit.gif" Runat="server" />

OnClick_Submit is defined in the code behind:
protected void OnClick_Submit (object source,
System.Web.UI.ImageClickEventArgs e)
{
if (Page.IsValid)
{
TopLabel.Text = "Success!";
}
else
{
TopLabel.Text = "Failed!";
}
}

I am able to compile the solution with no problems.

Problem: When I try to bring up the page, the page displays an error
that "'ASP.Contact_aspx' does not contain a definition for
'OnClick_Submit'". But OnClick_Submit is clearly defined in the
code-behind. So I'm guessing that there is some conflict with the
other controls/forms on the page. Does someone know how I should go
about debugging/fixing this problem?

Thanks!
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
You can only have one visible server form on the page at a time.
So you could have more than one server form as long as you only show one at
a time.
Or you can have more than one form visible on your page at a time, but only
one of them can be a server form (i.e. with the runat=server attribute.)
Server forms only support posting back to themselves (not to other pages.)

This will all become more flexible in .NET version 2.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"FayHuang" <fa****@mail.com> wrote in message
news:7d**************************@posting.google.c om...
Hi,

I am very new beginner to ASP.NET, but I inherited this ASP.NET
project from a person who left our company. So I hope that my problem
is fairly simple to solve.

Here is the background to the problem: I am working on the "Contact
Us" page for an e-commerce website. This page consists of the main
section of the page (Contact Us fields like First Name, Last Name,
etc.) and navigation sections (Navigation bar, Search textbox,
drop-down box & button, Subscribe now textbox & button). The side,
top, bottom navigation and Search fields have been put into separate
controls.

On the aspx page, I have the following defined:
<%@ Page language="c#" Codebehind="Contact.aspx.cs"
AutoEventWireup="false" Inherits="AOpenCenter.Contact.Contact" %>
<%@ Register TagPrefix="AOC" TagName="Footer"
Src="/controls/Footer.ascx" %>
<%@ Register TagPrefix="AOC" TagName="SearchBox"
Src="/controls/SearchBox.ascx" %>
<%@ Register TagPrefix="AOC" TagName="LeftNav"
Src="/controls/LeftNav.ascx" %>
<%@ Register TagPrefix="AOC" TagName="TopNav"
Src="/controls/TopNav.ascx" %>
<%@ Register TagPrefix="AOC" TagName="Header"
Src="/controls/Header.ascx" %>
<%@ Register TagPrefix="AOC" TagName="HeadTag"
Src="/controls/HeadTag.ascx" %>

I have a button that I want to submit my contact us fields.
Here is the button definition:
<asp:ImageButton ID="ContactUsButton" onClick="OnClick_Submit"
imageURL="/images/btnSubmit.gif" Runat="server" />

OnClick_Submit is defined in the code behind:
protected void OnClick_Submit (object source,
System.Web.UI.ImageClickEventArgs e)
{
if (Page.IsValid)
{
TopLabel.Text = "Success!";
}
else
{
TopLabel.Text = "Failed!";
}
}

I am able to compile the solution with no problems.

Problem: When I try to bring up the page, the page displays an error
that "'ASP.Contact_aspx' does not contain a definition for
'OnClick_Submit'". But OnClick_Submit is clearly defined in the
code-behind. So I'm guessing that there is some conflict with the
other controls/forms on the page. Does someone know how I should go
about debugging/fixing this problem?

Thanks!

Nov 18 '05 #2

P: n/a
"FayHuang" <fa****@mail.com> wrote in message
news:7d**************************@posting.google.c om...
Hi,

I am very new beginner to ASP.NET, but I inherited this ASP.NET
project from a person who left our company. So I hope that my problem
is fairly simple to solve.

Here is the background to the problem: I am working on the "Contact
Us" page for an e-commerce website. This page consists of the main
section of the page (Contact Us fields like First Name, Last Name,
etc.) and navigation sections (Navigation bar, Search textbox,
drop-down box & button, Subscribe now textbox & button). The side,
top, bottom navigation and Search fields have been put into separate
controls.

On the aspx page, I have the following defined:
<%@ Page language="c#" Codebehind="Contact.aspx.cs"
AutoEventWireup="false" Inherits="AOpenCenter.Contact.Contact" %>
<%@ Register TagPrefix="AOC" TagName="Footer"
Src="/controls/Footer.ascx" %>
<%@ Register TagPrefix="AOC" TagName="SearchBox"
Src="/controls/SearchBox.ascx" %>
<%@ Register TagPrefix="AOC" TagName="LeftNav"
Src="/controls/LeftNav.ascx" %>
<%@ Register TagPrefix="AOC" TagName="TopNav"
Src="/controls/TopNav.ascx" %>
<%@ Register TagPrefix="AOC" TagName="Header"
Src="/controls/Header.ascx" %>
<%@ Register TagPrefix="AOC" TagName="HeadTag"
Src="/controls/HeadTag.ascx" %>

I have a button that I want to submit my contact us fields.
Here is the button definition:
<asp:ImageButton ID="ContactUsButton" onClick="OnClick_Submit"
imageURL="/images/btnSubmit.gif" Runat="server" />

OnClick_Submit is defined in the code behind:
protected void OnClick_Submit (object source,
System.Web.UI.ImageClickEventArgs e)
{
if (Page.IsValid)
{
TopLabel.Text = "Success!";
}
else
{
TopLabel.Text = "Failed!";
}
}

I am able to compile the solution with no problems.

Problem: When I try to bring up the page, the page displays an error
that "'ASP.Contact_aspx' does not contain a definition for
'OnClick_Submit'". But OnClick_Submit is clearly defined in the
code-behind. So I'm guessing that there is some conflict with the
other controls/forms on the page. Does someone know how I should go
about debugging/fixing this problem?

Thanks!


I am not familiar with C but in VB you need to add in your code behind page
the following

Protected WithEvents ContactUsButton as ImageButton

There is probably something similar in C

hope that helps

Nov 18 '05 #3

P: n/a
hi Fay,
i think you need to make the Submit_OnClick public instead of protected.
let me know if this fixed it.

tim
"FayHuang" <fa****@mail.com> wrote in message
news:7d**************************@posting.google.c om...
Hi,

I am very new beginner to ASP.NET, but I inherited this ASP.NET
project from a person who left our company. So I hope that my problem
is fairly simple to solve.

Here is the background to the problem: I am working on the "Contact
Us" page for an e-commerce website. This page consists of the main
section of the page (Contact Us fields like First Name, Last Name,
etc.) and navigation sections (Navigation bar, Search textbox,
drop-down box & button, Subscribe now textbox & button). The side,
top, bottom navigation and Search fields have been put into separate
controls.

On the aspx page, I have the following defined:
<%@ Page language="c#" Codebehind="Contact.aspx.cs"
AutoEventWireup="false" Inherits="AOpenCenter.Contact.Contact" %>
<%@ Register TagPrefix="AOC" TagName="Footer"
Src="/controls/Footer.ascx" %>
<%@ Register TagPrefix="AOC" TagName="SearchBox"
Src="/controls/SearchBox.ascx" %>
<%@ Register TagPrefix="AOC" TagName="LeftNav"
Src="/controls/LeftNav.ascx" %>
<%@ Register TagPrefix="AOC" TagName="TopNav"
Src="/controls/TopNav.ascx" %>
<%@ Register TagPrefix="AOC" TagName="Header"
Src="/controls/Header.ascx" %>
<%@ Register TagPrefix="AOC" TagName="HeadTag"
Src="/controls/HeadTag.ascx" %>

I have a button that I want to submit my contact us fields.
Here is the button definition:
<asp:ImageButton ID="ContactUsButton" onClick="OnClick_Submit"
imageURL="/images/btnSubmit.gif" Runat="server" />

OnClick_Submit is defined in the code behind:
protected void OnClick_Submit (object source,
System.Web.UI.ImageClickEventArgs e)
{
if (Page.IsValid)
{
TopLabel.Text = "Success!";
}
else
{
TopLabel.Text = "Failed!";
}
}

I am able to compile the solution with no problems.

Problem: When I try to bring up the page, the page displays an error
that "'ASP.Contact_aspx' does not contain a definition for
'OnClick_Submit'". But OnClick_Submit is clearly defined in the
code-behind. So I'm guessing that there is some conflict with the
other controls/forms on the page. Does someone know how I should go
about debugging/fixing this problem?

Thanks!

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.