p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > ASP.NET and ASP > ASP.NET 2.0 > BOOK: Professional ASP.NET 2.0 AJAX ISBN: 978-0-470-10962-5
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET 2.0 AJAX ISBN: 978-0-470-10962-5
This is the forum to discuss the Wrox book Professional ASP.NET 2.0 AJAX by Matt Gibbs, Dan Wahlin; ISBN: 9780470109625

Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 2.0 AJAX ISBN: 978-0-470-10962-5 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 18th, 2008, 04:54 AM
sim sim is offline
Registered User
Points: 4, Level: 1
Points: 4, Level: 1 Points: 4, Level: 1 Points: 4, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default return value of Confirm in javascript not Working onClientClick

return value of Confirm in javascript not Working OnClientClick of button.
button is placed in updatePanel (AJAX).
JavaScript code for confirm is also in updatePanel(AJAX)

Code:
 
function chkleave()
{
var dat1 = document.getElementById("txttxtleavestartdate").value;
if (dat1.length != 10) 
{
returntrue;
}
var dat2 = document.getElementById("txttxtleaveenddate").value;
if (dat2.length != 10) 
{
returntrue;
}
if(Math.floor((new Date(dat2)-new
Date(dat1))/(1000*60*60*24))>document.getElementById("lblpendingleaves").innerHTML)
{
if (!confirm("Your Leave days are exceeding pending leaves. \n Your extra leaves will be considered 'Leave Without Pay'. \n Are you sure you want to send it for approval."))
return false;
}
}
 
<asp:ButtonID="btnSubmit"OnClientClick="return chkleave()"ValidationGroup="vali"CssClass="txtBox"BackColor="#1B3091"Font-Bold="True"ForeColor="White"runat="server"Text="Submit"OnClick="btnSubmit_Click"/>

Last edited by sim : December 19th, 2008 at 02:26 AM. Reason: made changes after response but still not working
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old December 18th, 2008, 04:40 PM
Friend of Wrox
Points: 4,805, Level: 29
Points: 4,805, Level: 29 Points: 4,805, Level: 29 Points: 4,805, Level: 29
Activity: 38%
Activity: 38% Activity: 38% Activity: 38%
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,323
Thanks: 3
Thanked 70 Times in 69 Posts
Default

You are missing a space between return and false so you are always getting a JavaScript error
and since apparently you don't have JavaScript debugging turned on you can't see that error.
The result is that the JavaScript code is effectively ignored.

You also do *NOT* do
return true;
when the confirm is true or the confirm is not invoked, so you can't even predict what will happen.
Yes, generally if you omit a return value from a JS function the result is the same as if you
returned true, but you can *NOT* guarantee that. If the function should return a value,
make sure that it ALWAYS does so, no matter what.

Your code should end with
Code:
    return true;
}

Last edited by Old Pedant : December 18th, 2008 at 04:43 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable Submit Button w/OnClientClick: Not Working kwilliams ASP.NET 2.0 Professional 4 August 25th, 2008 01:00 PM
JavaScript Confirm Box ricespn Classic ASP Basics 1 January 20th, 2007 12:48 AM
Javascript Confirm Message box itHighway Javascript How-To 5 September 25th, 2006 03:51 AM
Javascript Confirm dialog difficulty ayrton Javascript 1 May 20th, 2005 04:34 AM
need Confirm() with Yes/No buttons in JavaScript ehelpcornet ASP.NET 1.0 and 1.1 Basics 1 June 3rd, 2004 08:32 AM



All times are GMT -4. The time now is 04:16 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc