Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #21 (permalink)  
Old December 5th, 2006, 09:37 AM
Authorized User
 
Join Date: Dec 2006
Location: , , .
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar,
I have tried that one too.In both the cases(the one i sent you before and this one) when i click the button the pop up does come up although it doesnt do anything even if i click "ok" to it.What i am trying to do is not to get that pop up at all when i click the submit button.
Here is HTML for that one.
*****************
<HTML><HEAD><title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"content="http://schemas.microsoft.com/intellisense/ie5">
<script language="JavaScript">
  var needToConfirm = true;

  window.onbeforeunload = confirmExit;



  function confirmExit()
  {
    if (needToConfirm)
      return "You have attempted to leave this page. If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you sure you want to exit this page?";
  }
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form name="Form1" method="post" action="WebForm1.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE" value="dDw5NjU1MTU1Ozs+ZMe/YzNJ8mHHmvf5Yc5QSvBQljk=" />

<input type="submit" name="Button1" value="Button" id="Button1" OnClientClick="needToConfirm=false; return true;" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" />
</form>
</body>
</HTML>
***************************************

Thanks a lot
Kamal
  #22 (permalink)  
Old December 5th, 2006, 09:44 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Right I think I know what's going on. You posted this in an ASP.NET 2 forum, but your question is related to ASP.NET 1.x, right?

OnClientClick is new in ASP.NET 2 so you can't use it.

Instead, add the attribute in the page's Load event, like this:
Code:
protected void Page_Load(object sender, EventArgs e)
{
  Button1.Attributes.Add("onclick", "needToConfirm=false; return true;");
}
You can then remove the line with document.all["Button1"]..... from your code and it should work.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
  #23 (permalink)  
Old December 5th, 2006, 09:49 AM
Authorized User
 
Join Date: Dec 2006
Location: , , .
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar
This is awesome.You are too good.Its working fine in this dummy one but i have to replicate this thing in actual application and will write back to tell you.Also you were right about me being stupid enough to post this in ASP.Net2.0 when i was working in 1.1.But ia m so impressed.
Thanks a ton for your help
Kamal
  #24 (permalink)  
Old December 5th, 2006, 09:52 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

You're welcome. Hope it works out in the final application as well.

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
  #25 (permalink)  
Old December 5th, 2006, 10:33 AM
Authorized User
 
Join Date: Dec 2006
Location: , , .
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey Imar,
Your code is playing its magic in my application.Thanks a lot.I was working on this for 4 days now and was almost on verge of giving up.
I have still one question.Is there a way to customize the message that pop up displays?
Thanks
Kamal
  #26 (permalink)  
Old December 5th, 2006, 10:39 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

What method from which pop up?

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
  #27 (permalink)  
Old December 5th, 2006, 10:44 AM
Authorized User
 
Join Date: Dec 2006
Location: , , .
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar,
Right now my java script function looks like this
*****************
function confirmExit()
  {
    if (needToConfirm)
      return "Do you want to close the screen without posting the items?Select OK to close and Cancel to ";
  }
************************
But the message it displays on pop up is
"Are you sure you want to navigate away from this page?Do you want to close the screen without posting the items?Select OK to close and Cancel to.
Pree Ok to continue and Cancel to stay on current page."
**************************
I want to change this message to just one different line.Is this possible?And if yes how?

Thanks
Kamal
  #28 (permalink)  
Old December 5th, 2006, 06:48 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

I could be wrong, but I don't think you can. Looking at the message, I think this is something created by the browser.

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
  #29 (permalink)  
Old December 5th, 2006, 11:52 PM
Authorized User
 
Join Date: Dec 2006
Location: , , .
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar
So you mean even if i use something like
return=confirm("Do you want to exit?");
*****
It would still return the message like

"You are navigating away from this screen.Do you want to exit?"

Thanks
Kamal
  #30 (permalink)  
Old December 6th, 2006, 02:58 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Yes, I think so. This is a browser security setting to stop pages from redirecting you away without your approval.

There may be ways to work around this, but I don't know them...

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 


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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create a button in javascript in asp.net ? coolcoder2007 ASP.NET 2.0 Basics 0 October 26th, 2007 04:14 AM
In ASP,Client side javaScript code casimir Classic ASP XML 0 October 24th, 2005 12:24 AM
How to add client-side script to an ASP button BrianWren VB.NET 1 March 30th, 2005 05:27 PM
sessions wont persist bogins Beginning PHP 2 April 22nd, 2004 01:56 PM
ASP Upload - does object persist across pages? James Diamond Classic ASP Components 4 January 27th, 2004 09:41 AM



All times are GMT -4. The time now is 09:47 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.