form within form - main runat=server form is on master page...

The form in the content page is simply accessing an ajax/google javascript function, but because the master page has the "form... runat=server" bit in it, when the form in the content page is submitted, it submits the main form, not the google map form!  I don't want any postback on the google content page javascript form, just a "<form name="addr" method="post" action="" onsubmit="javascript:..." so that it simply runs the javascript on the page without a post back...

I investigated "attribute.add" but it seems I can't do that as the form I'm trying to add the attribute to is not "runat=server" and so the form id isn't recognised!


9/13/2007 7:15:28 PM 91979 articles. 4 followers. Follow

8 Replies

Similar Articles

[PageSpeed] 45
Get it on Google Play
Get it on Apple App Store

Since your 2nd form isn't doing a post back but rather running some script.  What I would do is get rid of the 2nd form (having nested forms almost always causes some kind of headache) and put in an image, hyperlink or label (<div>) and have the OnClick method call your javascript.

<div style="cursor: hand;" OnClick="javasript: alert('test'); return false;">Click here to execute</div>


Dave Yancey
My Blog
9/13/2007 7:41:10 PM

Yeah, good thinking. It certainly fires the javascript now, but something about the page set up is still making it bomb out at some point and reload the whole page before the script finishes. I've got debug points on and it happens after it goes off to do a google map function and before it comes back to the page javascript again... The whole page works perfectly if it's not a master/content set up though.

I think I may need to investigate putting it inside an updatepanel or something...

Thanks for the help.

9/13/2007 8:16:43 PM

if the google map function is making anykind of call back to the server then yes I can see a postback being called.


Dave Yancey
My Blog
9/13/2007 8:24:06 PM

just thinking... is it possible that in the master page I can detect if the page loaded is the google map page and, if so, disable postback whilst that page is loaded?

9/13/2007 8:28:54 PM

because the googlemap page is called by javascript I don't believe youcan detect it.  Also I don't believe you can disable a postback once its been called.

Dave Yancey
My Blog
9/13/2007 9:01:18 PM

no, no... I meant the postback on the form that's embedded in the master page. On my google map page there are no controls that need postback.

9/13/2007 9:04:12 PM

not that I am aware of. 

What you could try however is take this page out of your main masterpage and either just build your page wiht out a masterpage, or create a 2nd masterpage for this page that does not have the form in it.  Thus removing any postback.

Dave Yancey
My Blog
9/13/2007 9:21:30 PM

Ah. Now that sounds like good thinking! Thanks! Will report back after experimentation

9/13/2007 9:52:30 PM

Similar Artilces:

Forms or No Forms
Hope this isn't a repeat.  I looked and didn't find anything. Say for example you had a web page with around 20 fields retrive and update to a database with differing datatypes.  Some fields will have some special controls (dropdowns, radios, buttons, etc) that interact with other parts of the page.  What is the best and/or most efficient code to make the page. Would you use a Formview bound to a standard SQL connection and edit the templates. Use a Formview bound to an Object Data Source and edit within the templates. Or use an Object Data Source and bind the...

A form within a form
I have a problem with setting up a google search box within a table on my site. The code for the search box is a form and my entire visible area is inside another form. Like this: Now the first is the entire visible area to create dynamic pages, and the second form is the search box. This setup does not work at all, I get different visuals in different browsers. Is there an easy way to fix this or are forms within forms just a bad case...? , MacGoose  Maybe even you can fix the issue but having form inside another form is not very good concept. You should rather send ...

Forms within forms?
Hi all, I have a question regarding forms. I have a datagrid that has client side form tags embedded within the templatecolumn tags. It looks something like this. <form runat="server"> <datagrid runat="server"> <columns> <asp:templatecolumn> <itemtemplate> <form action="post.aspx"> ---form elements </form> </itemtemplate> </asp:templatecolumn> </columns> </datagrid> </form> Everytime I try to submit something using the client side form, the ...

Form within a form!
I am having a problem with javascript. I have a piece of javascript within a user control. This javascript is within a form. But when i place the user control on a .aspx page it tells me i cant have a form within a form.Is there anyway around this? You cannot have a form within a form.A typical way to handle this situation is to place the <form> on the page, inside of which you place your user controls. Because the user controls are within the <form> on the page, the user controls do not need their own form. Like this:<%@ Page %><%@ Register TagPrefix="My" TagName="Hea...

form within the form
I need to have form code so i can submit data to another site. The method is post and the action is on another server. I can't do a post request from the aspx code behind because I need the actual client browser to submit, request and load the form for cookie, IP address and other validation reasons that happens on the submitted site. Is there anyway to have                                         ...

form within form
Hi,I have a <form runat="server"> at the start of my page, as i have some server controls (asp:label, etc...) in the page.  I need to integrate a paypal button onto the page, but the problem is paypal buttons needs to be within a form tag.  they provide the code and it starts with <form....></form>  Is there anyway around this?  the form has hidden fields values that are submitted to the paypal page, so i need to make sure those are sent to their site. Thanks.  Hello pkd,> the problem is paypal buttons needs to be within a form t...

non .net form issue within a .net form tag
this may be a bad question... but I am adding a shopping cart to my website and it calls for the following code for the 'buy now' buttons: <form method="POST" action=><input type="hidden" name="ID" value="IDName"><input type="hidden" name="Describe" value="IDName Description"><input type="hidden" name="Price" value="100.00"><input type="hidden" name="QtyMax" value="1"><input t...

how to use form tag in the content page while master page form tag is in use?
Hi there, i have created a bug report form in the content page which uses the master page template. In the master page i am using the menu which should be in the form tag. when i use the form tag in the content it gives me the error as cant use more than one form tag. how can i resolve it. i hav searched in this forum for tht.. i got links which says to disable the content page form tag as form.visible= false. In my situation i cant disable any of the form tag either inthe master page( menu with in the form tag) or content page ( bug report form with server controls with...

form runat=sever + other form
Hello!This is probably a dumb question, but I cant figure this out ...I have master page with following structure:<body>    <form id="form1" runat="server">...  HTML content ...   <form action="" id="form2" method="post">       ... fields ...       <input type="submit" value="submit">   </form>... HTML content ...    </form></body>here's the problem .. when i click on submit in form2, it submits form1 instead ... if i clo...

Single page form or Multi-page form?
Currently, I have a single, one form ASP.NET page.  When the page loads there is a textbox with a submit button.  You are asked to enter an id and, on submit, it checks my database for a match.  If a match is not found then additional fields appears on the same page.  (FYI: The fields are wrap in a div tag.  The div tags visibility set to "hidden".  On postback I reset the visibility attribute to "visible" as long as there isn't a match.  If there IS a match then the div remain hidden and the user is asked to try again.) Th...

Page Form and Windows Form
If i create a class that inherits from Windows.Form, Can i use this class in my ASP.Net Page? i know one is client-server aplication, adn the other web aplication, but could i?...

Master pages and forms
In my site, page foo.aspx is stored in /pages/foo.aspx  (/ indicates the site root)Foo.aspx uses a master page which is stored at /site.masterI put a LoginStatus control in the master page, in ContentPlaceHolder1. Foo.aspx merely inherits ContentPlaceHolder1, it does not provide any custom content for that item.For various reasons, I am using URL Rewriting to redirect users to pages on my site using server-side redirects.So for example, to get to /pages/foo.aspx, the user merely needs to type effectively hides complicated page URL's from the browser, but ...

A page can have only one server-side Form tag
I have a web user control in my web page.  The user control (ascx) consist of a text box and button. The web page consist of text boxes and buttons also.  Both pages have form tags with runat=server.  When I run the web page it comes up with the error "A page can have only one server-side Form tag." Both the user control and web page need the form tag with runat=server.  Is there a way I can code these pages where there won't be a conflict between the web user control and the web page? Thanks   JohnMo wrote:Both the user control and web page need the form tag wit...

form inside runat=server form-why won't this one work?
I made a button on paypal that is a form. When I place it on my page that already has a runat=server form, it does not work. It just sends me to the page it is on. I have seen this work before, but I dont know how. my form tags look something like this:<body> <form runat=server> a few controls <form action="" method="post"> <input type="image" src="" border="0" name="submit" alt="Make payments with P...

forms and form validation
am new to asp. i have recently been given the task of redisigning an existing website. the old site included a few forms which i have incorporated into the new site layout. unfortunately, since the redesign, the forms no longer work. i have tried to be as detailed as possible, i am quite sure that all the links are in order. i am assuming that their must be something simple that i have neglected as i have not changed the .js files or the path locations. please advise. Thank you. Hi primalxx, Please let us know, what is not working, why it is not working, and what kind of error...

Web resources about - form within form - main runat=server form is on master page... -

Resources last updated: 11/21/2015 6:43:43 AM