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

Buttons and

I have two buttons on my ASP.NET 2.0 form:

<asp:Button id="btnSubmit" Text="Submit" OnClick="btnSubmit_Click"
CausesValidation="true" runat="server"></asp:Button>
<asp:Button id="btnCancel" Text="Cancel" OnClick="btnCancel_Click"
CausesValidation="false" runat="server"></asp:Button>

The following HTML code is generated:

<input type="submit" name="btnSubmit" value="Update"
onclick="javascript:WebForm_DoPostBackWithOptions( new
WebForm_PostBackOptions(&quot;btnSubmit&quot;, &quot;&quot;, true,
&quot;&quot;, &quot;&quot;, false, false))" id="btnSubmit" />
<input type="submit" name="btnCancel" value="Cancel" id="btnCancel" />

Why the onclick event handler is called for the first button that has
CausesValidation="true", but not for the other one that has
CausesValidation="false"? The CausesValidation property should not have any
influence on the event handler. Yet when I set CausesValidation="true" for
the second button - the onclick event is called.

Thanks,
Leszek
Aug 7 '07 #1
2 1788
Thanks.

The problem was that the button did not generate postbacks unless
CausesValidation was set to true.
It was a very weird problem indeed. I have solved it. It turned out I had to
use the following tags to include java script code:
<script type="text/javascript" src="grid.js"></script>
instead of
<script language="javascript" src="grid.js" />

Strange - but now the form is working like a charm.

Leszek

"George Ter-Saakov" <gt****@cardone.comwrote in message
news:eD***************@TK2MSFTNGP02.phx.gbl...
That's how Validation is done.
When button has CausesValidation=true then ASP.NET automatically generates
code to run JavaScript validation before submitting the form.

Obviously when CausesValidation=false the button becomes regular submit
button. Since no JavaScript needs to be run.

George.

"TarTar" <sp*******@lovely.spamwrote in message
news:eJ*************@TK2MSFTNGP05.phx.gbl...
>>I have two buttons on my ASP.NET 2.0 form:

<asp:Button id="btnSubmit" Text="Submit" OnClick="btnSubmit_Click"
CausesValidation="true" runat="server"></asp:Button>
<asp:Button id="btnCancel" Text="Cancel" OnClick="btnCancel_Click"
CausesValidation="false" runat="server"></asp:Button>

The following HTML code is generated:

<input type="submit" name="btnSubmit" value="Update"
onclick="javascript:WebForm_DoPostBackWithOptions (new
WebForm_PostBackOptions(&quot;btnSubmit&quot;, &quot;&quot;, true,
&quot;&quot;, &quot;&quot;, false, false))" id="btnSubmit" />
<input type="submit" name="btnCancel" value="Cancel" id="btnCancel" />

Why the onclick event handler is called for the first button that has
CausesValidation="true", but not for the other one that has
CausesValidation="false"? The CausesValidation property should not have
any influence on the event handler. Yet when I set
CausesValidation="true" for the second button - the onclick event is
called.

Thanks,
Leszek



Aug 7 '07 #2
That's how Validation is done.
When button has CausesValidation=true then ASP.NET automatically generates
code to run JavaScript validation before submitting the form.

Obviously when CausesValidation=false the button becomes regular submit
button. Since no JavaScript needs to be run.

George.

"TarTar" <sp*******@lovely.spamwrote in message
news:eJ*************@TK2MSFTNGP05.phx.gbl...
>I have two buttons on my ASP.NET 2.0 form:

<asp:Button id="btnSubmit" Text="Submit" OnClick="btnSubmit_Click"
CausesValidation="true" runat="server"></asp:Button>
<asp:Button id="btnCancel" Text="Cancel" OnClick="btnCancel_Click"
CausesValidation="false" runat="server"></asp:Button>

The following HTML code is generated:

<input type="submit" name="btnSubmit" value="Update"
onclick="javascript:WebForm_DoPostBackWithOptions( new
WebForm_PostBackOptions(&quot;btnSubmit&quot;, &quot;&quot;, true,
&quot;&quot;, &quot;&quot;, false, false))" id="btnSubmit" />
<input type="submit" name="btnCancel" value="Cancel" id="btnCancel" />

Why the onclick event handler is called for the first button that has
CausesValidation="true", but not for the other one that has
CausesValidation="false"? The CausesValidation property should not have
any influence on the event handler. Yet when I set CausesValidation="true"
for the second button - the onclick event is called.

Thanks,
Leszek


Aug 7 '07 #3

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

Similar topics

8
by: Ralph Freshour | last post by:
Is it possible to inhibit the browser Back/Fwd buttons via PHP? Thanks...
4
by: Bob Lehmann | last post by:
Hi, I pretty sure I've seen this problem addressed before, but I can't find any references. The short story is that I have I have multiple submit buttons on a page, each providing different...
2
by: Aravind | last post by:
Hi folks. I have a form, frmHistory, which has 4 command buttons: Sort Title (cmdSortTitle), Sort Name (cmdSortName), Due Today (cmdDueToday), and Due List (cmdDueList). Sort Title and Sort...
5
by: Lyn | last post by:
Hi, I hope someone can help. I have a main form which mostly fills the Access window. In the bottom half of this form I have a tab control to display various types of data related to the main...
0
Denburt
by: Denburt | last post by:
This code is for a Toggle Button layout on a form, with this code you can set a number of toggle buttons visible and have multiple submenus that will stay hidden when not in use. My main menu is set...
4
by: Ron | last post by:
I want to create 10 buttons on a form at runtime, the code below is only creating one button labeled 1. Any idea what I am doing wrong? Public Class Form1 Public code(10) As String Public...
3
by: Ron | last post by:
Can anyone help me out? I am trying to add buttons numbered one through 10 at runtime to a form. I think they are getting added but they seem to be getting stacked one on top of each other. so...
2
by: dpazza | last post by:
Hi, I'm creating a quiz on using a form in VB 2005 express. I have four sets of questions and answers (labels and radio buttons) and I change between which set of questions is currently shown on...
4
by: Blasting Cap | last post by:
I have a page that has a number of radio buttons that will be displayed to different access levels of a user who logs in to my website. For instance, if there are a dozen buttons, user1 will see...
2
by: remya1000 | last post by:
hai i'm using Vb.net. i'm creating 64 dynamic created buttons of 8 rows and 8 columns. And i have 1 Go button, 1 textbox. those were created dynamically. if i enter one number inside textbox and...
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: 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:
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.