473,387 Members | 1,798 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,387 software developers and data experts.

<form> element in pages running under a MasterPage

I'm a little confused about something.

I have a "Contact Us" page that I'm developing that runs within a
content page under a master page.

I was plagiarizing fairly liberally from some other pages that I had
seen that worked, so I ended up with a <formelement containing a
number of text boxes, and a submit button.

In the codebehind for the button click event, where I went to
construct the mail message from the text in the textboxes, I found
that all of the text boxes were coming back as empty strings, even
though they were being displayed with text in them. I tried several
things to get it work right, and the thing that finally worked (or at
least the first thing that I tried that worked) was removing the
<formelement.

After doing some reading, I found that forms cannot be contained
within forms, and since the MasterPage places the ContentPlaceHolders
inside a <formelement, I needed to remove it. Is that a correct
understanding, and if so, how do you ever have a form on a content
page? Or do you even need it?
Jul 30 '08 #1
2 1943
You simply do not need the <formtag in the content page, because it is
already inside a <formtag (the one in the Master Page). Because an ASP.NET
Page is only allowed to have one <form>, you do not need it. When creating a
Content Page, basically just pretend the <Contenttag is your <formtag.
If you want to know more details (or for a better explanation, I'm not
always great at explaining things), just look up the details about Master
Pages, but it sounds to me like you've pretty much answered your own
question already. Good Luck!

"daveh551" <ge****@gmail.comwrote in message
news:ae**********************************@27g2000h sf.googlegroups.com...
I'm a little confused about something.

I have a "Contact Us" page that I'm developing that runs within a
content page under a master page.

I was plagiarizing fairly liberally from some other pages that I had
seen that worked, so I ended up with a <formelement containing a
number of text boxes, and a submit button.

In the codebehind for the button click event, where I went to
construct the mail message from the text in the textboxes, I found
that all of the text boxes were coming back as empty strings, even
though they were being displayed with text in them. I tried several
things to get it work right, and the thing that finally worked (or at
least the first thing that I tried that worked) was removing the
<formelement.

After doing some reading, I found that forms cannot be contained
within forms, and since the MasterPage places the ContentPlaceHolders
inside a <formelement, I needed to remove it. Is that a correct
understanding, and if so, how do you ever have a form on a content
page? Or do you even need it?

Jul 30 '08 #2
Also keep in mind - AsP.Net is a total paradigm shift from the days of
Classic ASP -
You don't need a form tag for every button event any more

David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup
http://cg.augustwind.com - ControlGrouper (ASP.Net Control)
"daveh551" <ge****@gmail.comwrote in message
news:ae**********************************@27g2000h sf.googlegroups.com...
I'm a little confused about something.

I have a "Contact Us" page that I'm developing that runs within a
content page under a master page.

I was plagiarizing fairly liberally from some other pages that I had
seen that worked, so I ended up with a <formelement containing a
number of text boxes, and a submit button.

In the codebehind for the button click event, where I went to
construct the mail message from the text in the textboxes, I found
that all of the text boxes were coming back as empty strings, even
though they were being displayed with text in them. I tried several
things to get it work right, and the thing that finally worked (or at
least the first thing that I tried that worked) was removing the
<formelement.

After doing some reading, I found that forms cannot be contained
within forms, and since the MasterPage places the ContentPlaceHolders
inside a <formelement, I needed to remove it. Is that a correct
understanding, and if so, how do you ever have a form on a content
page? Or do you even need it?

Jul 30 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Sims | last post by:
Hi, This will validate, (http://validator.w3.org/) <form method="POST" action="" name='xForm' style='background:inherit;'> <table style='background:inherit; width:100%;'> <tr width=80%> <td>...
7
by: bc9am | last post by:
Hi, I'm having problems with the <form> tag creating some unwanted whitespace. I did a search on this forum and came across this link: http://www.cs.tut.fi/~jkorpela/forms/extraspace.html ...
2
by: Gram | last post by:
Hello, Can anyone help with the following. I have a search option on a site, using a form, but the FORM element throws off all the layout. Is there a way to make a search work, without using...
4
by: Howard Jess | last post by:
In Opera 8.01 (Linux; Build 1204) and in Opera 7.54 (Windows XP; Build 3865), my form disappears from the HTML markup (below). To summarize: 1) In a <script> block in the <head> I create a form...
9
by: Warren Post | last post by:
At <http://snow.prohosting.com/srcopan/src/search.html> I have a simple form, using the following code provided by my site search provider: <form method="get"...
6
by: snacktime | last post by:
I've searched and searched and have not found a solution to suppress the margin on form or href tags so that there is no space before or after the tag. The only way I have found to do this is to...
4
by: rob c | last post by:
This is a minor thing and only appears in IE (so far), but I'd like to know to correct it (if possible). Whenever I use a form on a webpage, Explorer always leaves a blank line following the...
1
by: semifor | last post by:
I've been using a simple technique that works adequately, for me, to restrict a web page to the viewport. A typical page will have a header, a table wrapped in a <divwith "overflow: auto", and...
4
by: Magnus Warker | last post by:
Hello group, I am producing a form within a table: <table> <tr> <td> <form> ... </form>
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.