473,399 Members | 3,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

How to Handle Multiple Forms on a Page

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
3 1755
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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: James X. Li | last post by:
Is there a way to implement multiple login forms for ASP.NET applications? With our application we want to implement simple login form for normal resources (downloadable files), but more rigorous...
8
by: TJS | last post by:
what are folks doing to get around limitation of one server form per page ?
12
by: Aaron Smith | last post by:
What is the best way to handle data in a multiple user environment? We have forms that will allow users to add edit and delete data from a table on SQL server. The data could be edited on multiple...
7
by: Siv | last post by:
Hi, I have an MDI application that uses a generic "ShowPage" routine in a module that is called when I want to display a child form. The basic idea is that in the module I have declared each form...
5
by: RichG | last post by:
I'm looking for a way to bring an open form to the top. I know that is I open a form directly with form1.show() and then later, while the form is open I do another form1.show(), that I will get...
3
by: imrantbd | last post by:
I need array type name like "destList" must use for my destlist select box,not a single name.Or need a solution to capture multiple value of "destList" select box and send all selected value in php...
5
by: c676228 | last post by:
Hi everyone, my colleagues are thinking about have three insurance plans on one asp page: I simplify the plan as follow: text box:number of people plan1 plan2 plan3
3
by: Yehia A.Salam | last post by:
hello, I have to deal with the weird limitation of asp.net, as I need to have multiple forms on my page, well three at least actually, one for the login, one for the search engine, and another...
1
by: draw | last post by:
I have one container page "container.htm" In this container I have multiple iframes "iframepage1.htm", "iframepage2.htm", etc. and one button firing a js script to submit. In every iframe page I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.