954,593 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

alert message

suppose when user click on edit button, he should not be allowed to go any of hyperlinks or tabs or any other other page. after clicking save or close buttons he shold be allowed to move. even though if tries to click on any hyperlinks or tabs he shold get an alert message to make changes or not. just as MS-word if open blank document n click on close it will ask u for save. aspnet c# web application

sasindagi
Newbie Poster
14 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

are you asking for an alert message? If so, javascript is always:

onclick="return confirm ('Message to confirm');"

If you want an advanced one, like when the user clicks no or yes, a new alert box will appear saying that the changes were successful or aborted, then follow the article below:

http://aspnet.4guysfromrolla.com/articles/021104-1.aspx

SheSaidImaPregy
Veteran Poster
1,080 posts since Sep 2007
Reputation Points: 43
Solved Threads: 68
 

You will need to set an onchange or onkeydown event in all of your editable controls to set a global dirty flag. Check this flag in the window.onbeforeunload event and simply return a string to it, the browser will do the rest.

<html>
<head>
<script type="text/javascript">
    var unsaved = false;
    window.onbeforeunload = function(){if(unsaved){return "You have unsaved data. Are you sure you wish to leave this page.";}};
</script>
</head>
<body>
<input type="text" id="txt1" onkeydown="unsaved = true;"/>
</body>
</html>
hollystyles
Veteran Poster
1,182 posts since Feb 2005
Reputation Points: 262
Solved Threads: 68
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You