473,387 Members | 1,549 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.

ASP.NET - C#: Button not submitting form which has onsubmit attribute

56
Hi all,

I'm absolutely lost and have no idea why this is happening.
I have a master page where the form resides. I set an onsubmit attribute to call a method which sets a variable to true

Expand|Select|Wrap|Line Numbers
  1. <form id="form1" runat="server" onsubmit="setVariable();">
  2.  
  3. the function I call is :
  4.  
  5. function setVariable()
  6. {
  7.     aVariable= true;// aVariable is a global var in the js file
  8. }
When I use buttons which have the UseSubmitBehavior property set to true (which is true by default) the form will not submit. I need these buttons to be using submit behaviour.
The serverside events of button click are not being called.

When I remove the onsubmit attribute all works fine.

Can anyone help
Thanks
Luk
Aug 4 '08 #1
1 6346
Frinavale
9,735 Expert Mod 8TB
Hi all,

I'm absolutely lost and have no idea why this is happening.
I have a master page where the form resides. I set an onsubmit attribute to call a method which sets a variable to true

Expand|Select|Wrap|Line Numbers
  1. <form id="form1" runat="server" onsubmit="setVariable();">
  2.  
  3. the function I call is :
  4.  
  5. function setVariable()
  6. {
  7.     aVariable= true;// aVariable is a global var in the js file
  8. }
When I use buttons which have the UseSubmitBehavior property set to true (which is true by default) the form will not submit. I need these buttons to be using submit behaviour.
The serverside events of button click are not being called.

When I remove the onsubmit attribute all works fine.

Can anyone help
Thanks
Luk
ASP.NET uses it's own method and automatically sets the forum to call their generated function; therefore, when you set the forum's onsubmit attribute things don't work. I remember trying this not to long ago and just figured that this is not allowed (a bug).

I ended up setting my button's clientClick to call the function instead of using the onsubmit.

If you find out how to get around this, let us know. Otherwise, I suggest using the clientclick work-around.

-Frinny
Aug 5 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Syed Ali | last post by:
Hello, I have 1 HTML form with 4 submit buttons and 10 textfield entry areas. If submit button1 is pressed I need to make sure that all 10 textfield entries have been filled before submitting...
4
by: Frank Way | last post by:
Hi all, I've googled this one to death, and still can't find an answer. Not sure I'm asking the right question, but here goes: Have a form with an onSubmit that has some javscript to disable...
1
by: chad.arimura | last post by:
I've got a form inside a PHP script that posts to itself, does some processing on the PHP side, and if it looks good, PHP sends a HEADER command that redirects the user out. All was fine until I...
2
by: Sean Dockery | last post by:
Which is the following is correct? a) <form ... onSubmit="return checkData()"> b) <form ... onSubmit="return checkData();"> c) <form ... onSubmit="checkData()"> d) <form ......
4
by: Wysiwyg | last post by:
I need to validate a form to ensure that all of the fields add up correctly. I can't do this while the user is entering data since validation needs to be done after the entry is completed. What's...
1
by: Bill_W_Stephens | last post by:
I need a form with two buttons and ability to detect which button was pressed. I got this code to work using a javascript global variable, but I know there must be a better way using DOM. Any...
2
by: darrel | last post by:
I am using a javascript WYSIWYG text editor for our CMS. To grab the proper content we need to add a javacsript call to the form: Form1.Attributes.Add("onSubmit", "myOnSubmitEventHandler();") ...
18
by: Axel Dahmen | last post by:
Hi, trying to submit an ASPX form using the key (using IE6) the page is not submitted in my web project. Trying to debug the pages' JavaScript code I noticed that there's some ASP.NET client...
10
by: k3pp0 | last post by:
Hello. Here's my example form: <form method="get" action=""> <p> <input type="radio" name="radio_example" id="radio1" value="radio1_val" /> <label for="radio1">radio button one</label> </p>
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: 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: 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
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.