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

Recommended Answers

All 2 Replies

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

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>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.