UserControl and ModalPopUp prompt when user leaves page

 Hi,

I have some UserControl which is used in many pages in my application. I want to prompt user (by ModalPopUp) that there is an unsaved data in a control. This prompt should be when user leaves page and there is an unsaved data in my UserControl.

Please help me with this issue.

0
steensh
6/25/2008 7:54:15 AM
asp.net.ajax-ui 9760 articles. 0 followers. Follow

4 Replies
479 Views

Similar Articles

[PageSpeed] 45

 <body onLoad="closing=true" onUnload="if (closing) alert('you are closing window');"> check for the values in your use control in unload event and call a prompt  window to save or cancel


Abipeter
0
abipeter1983
6/25/2008 9:05:26 AM

When user change something in data, that time you can set the flag or set in session

So at the time of form closing you can check the flag value & gives the message to user


Chetan Sarode
Software Engineer,
Approva Systems Pvt Ltd,
Pune, India.
0
chetan
6/26/2008 3:28:41 AM

 I give an example code, so you can understand what I want to do:

  

window.onbeforeunload = function (e) 
{
if (isChanged())
{
//show pop up and wait for user answer
if (answer == save data) save data on client side
}

//close or redirect
}

<asp:Button ID="btnConfirm" runat="server" Style="display: none" />

<asp:Panel ID="pnlConfirm" runat="server" Style="display: none">
<%--panel definition with 2 buttons: btnConfirmOK and btnConfirmCancel --%>
</asp:Panel>


<mpe:ModalPopupExtender ID="mpeConfirm" runat="server"
OkControlID="btnConfirmOK"
CancelControlID="btnConfirmCancel"
PopupControlID="pnlConfirm"
TargetControlID="btnConfirm">
</mpe:ModalPopupExtender> 
 

My question is how to display my own popup confirmation and get answer from user so after that onbeforeunload function close/redirect user  to another place. Default, onbeforeunload displays borwser's like confirmation. In other words: how to make ModalPopUp to act like standard browser confirmation in onbeforeunload function.

Maybe there is another way to do this without onbeforeunload? A whole procedure should be done in client side (without postback). Thanks for your replies.

0
steensh
6/26/2008 5:16:08 AM

Hi,

 

how to make ModalPopUp to act like standard browser confirmation in onbeforeunload function.

 

First, when your redirect your current page to another url in the ButtonClick event of OKButton, the onbeforeunload client event would still be triggered. Second, “A whole procedure should be done in client side” not sure what you exactly mean by that. But since you are using a server control Button, then maybe adding a clientside event or using callback mechanism can match your needs.

 

Thanks.

 


Michael Jin.
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Nai
7/1/2008 3:15:33 AM
Reply:

Similar Artilces:

prompt before leaving page (ModalPopUp)
Hi,I want to use a ModalPopUpExtender to prompt user that there is some unsaved data on page. It should works like 'onbeforeunload' function, but I want to use my own popup for a confirmation (ModalPopUpExtender). Please provide me with some sample code. Thanks a lot. there is some sample.. http://mattberseth.com/blog/2007/07/modalpopupextender_example_for.html http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ModalPopup/ModalPopup.aspx i hope these help youihsany######Make It Easy--------------dont forget to click <Mark As Answer>------------------ I doubt very much th...

Detect user leaving page and prompt
I have a asp.net 2.0 master page that contains one content page. On this content page I have 3 formviews. Does anyone know how to check to see if these formviews are in edit mode if they are prompt the user before leaving the page (ie X button or back button on browser) Thank you Spafa9-------------Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.          protected void Page_Load(object sender, EventArgs e)      &nb...

Prompting a user to save data when leaving a page
I've seen articles written on this subject for v1 but nothing as yet for v2. I use a master page and content pages with formview controls (& sqldataadapters) for data input. I want to be able to prevent a user from moving off the page when they have unsaved data on either an insertitem or edititem template. From reading the earlier articles I'm unclear as to whether the new features in v2.0 will still allow these ideas to work. Before going ahead and trying (and potentially wasting time) I thought I'd ask what other people are doing as I'm sure this is a common situation. I neve...

How do you open a new page in ajax .net ModalPopup?
 In classic asp I used new Ajax.Request('/default.asp', {..... But in .net I can't seem to find anything about opening a new modal popup of a new page. Thanks.  To really show another page in a modal popup you would have to use an iframe inside the popup.-- "Mark As Answer" if my reply helped you --...

Prompt User to Save changes before leaving the page
Hi, I have several pages where I use formviews.  What's the best way to promt the user to save the changes if they try to leave the page? Thanks. You will need to use the javascript window.onBeforeunload event.  Here is a link to an article describing exactly how to do this. http://www.4guysfromrolla.com/webtech/100604-1.shtml Thank you, This looks like a useful method of doing it, but the article is old.  I am having trouble figuring out mainly how to do it with formviews.  Since the controls are in a formview, how can you do that in javascript?  T...

System.Web.UI.Page and Ajax.net
 İ use .net 2005 and ajax.net.Normally i use System.Web.UI.Page,my webpage is working.But in here we use other page that extends System.Web.UI.Page.if i extend my class to our  webpage my ajax.net isn't  working. My error explanation is: sys.webfrom.pagerequestmanagerparserErrorException:the message received from the server could not beparsed.Common causes for this error are when the response is modifies by calls to Response.write(),response filters,httpmodules,or server trace is enabled. Details:Error parsing near'itle||Untitled PAge|<script language=J...

how to clear the page values when using ajax and modalpopup extender and user control
iam using two user controls u1 and u2 for this usercontrols iam using another user control p1 .and iam applying ajax in the page where these usercontrols are there .the problem is when i click one button the u1 is getting fired . and it is comming like a popup because iam using ModalPopupExtender with out flickering the page.but when iam giving some values and closing the popup and agin opening then the old values in the control u1 is not clearing and at the same time since iam using a uc p1 in the u1 .now wen iam opening the u2 .using javascript im handling some function where this p1 contr...

How to ask a user whether he wants to leave a web-page during an ajax request (IE)?
Hello! I have an ajax-enabled website. For example, there is a button with a Response.Redirect() in the click event handler. I need to ask the user if he wants to leave a page or not after the button clicked and the Response.Redirect() starts to execute. When I try to use a javascript window.onbeforeunload with a confirm message and the user answers he wanted to leave a page, there is an unspecified error raised. How can I achive the desired functional? You can use asp link button or html button. My example is using html button. in .aspx file <script type="text/javas...

Not preserving the state of the Ajax page when user gets out of page
Hi,  I have an asp.net ajax page. When the user gets to another page, and then returns to the page, page is preserved (not reinitialized) I want it to be reinitialized everytime user gets out of page. I tried to play with Response.Cache, didn't work. Any suggestions I believe this question should have a trivial answer. But how? Without Ajax, a similar situation was avoided using smartnavigation=false. With Ajax, whats the answer?   Hi onura Based on my understanding, you are talking about maintain the Scroll Position when back to the page, and you need the Scr...

System.Web.UI.Page and System.Web.UI.UserControl
the below code works great for myBasePage.cs that inherits from : System.Web.UI.Page and the same code i copied to another base class which is myBaseControl.cs that inherits from : System.Web.UI.UserControlthe below code does not work for myBaseControl.cs and after i look at the MSDN i found that i have to use   SaveViewState()LoadViewStatemy qustion is how do i make my code use the above two methods (SaveViewState & LoadViewState) ? protected override void SavePageStateToPersistenceMedium(object viewState){string key = Request.Url.ToString() + "__VIEWSTATE";System.IO.Memo...

How to maintain page scroll position after clicking AJAX Rating control in AJAX ModalPopup
HiHow can i maintain page scroll position.I have placed a AJAX Rating Control in ModalPopup Extender, but when i click on rating control in modalpopup extender my page scroll position is changing it is moving to the top of page.I have used maintainScrollPositionOnPostBack ="true"  for pages but it does not work Can any help to solve this problem.regardsprashant  Try this. "Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."  Hi Thanks for your reply.Rating1.Attributes...

Is it possible to load a usercontrol from a class which is not inherited from System.web.ui.Page(or UserControl)
I have a class.which is inherited from System.Object. , But I want to load a usercontrol in this class. Is it possible ?  and how to do it?Thanks. I think more info is needed as to just what you are trying to do, as the basic idea of a User Control is for display purposes, and there is no display mechanism for a System.Object.NC......

I wrote code Response.Redirect then page is not redirected to reqquested page ( ajax.net)
I wrote code Response.Redirect then page is not redirected to reqquested page  (with ajax.net) make sure that your target URL is valied and correct... or the problem might be from your browserRegards...Nassar, RamiMy Blog || E-Mail Don't forget to click "Mark as Answer" on the post that helped you.This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped. dear, just paste the code so that we can assist u accordinglyKind Regards,Saurabh Sharmaonly dead fish swim along the flow of river, learn to make yo...

Re: How to control the columns displayed on a .net page depending on the page the user is coming from
  Hi all,    I have got two pages on wy website which contains a form to submit data into the same database. The two pages have also got a link to view the submitted data. The challenge I have got at the moment is, I want to be able to control columns the users see depending on the which of the two pages they are coming from. I know I can simply create two more separate pages but I don't want to do that. I feel I can be clever and achieve this with a conditional statement but to be honest, I don't know how to go about this. Could you please help me on thsi? Bas...

Web resources about - UserControl and ModalPopUp prompt when user leaves page - asp.net.ajax-ui

'url' Top Users - Stack Overflow
current community chat blog Stack Overflow Meta Stack Overflow Stack Overflow Careers your communities Sign up or log in to customize your list. ...

List of content management frameworks - Wikipedia, the free encyclopedia
.NET Framework , works with SQL Server, VistaDB , with XSLT or .NET UserControls Text is available under the Creative Commons Attribution-ShareAlike ...

OPAC Discovery
Switch Language To switch to a different language, select from the following list: English French Spanish Italian British Bulgarian Galician ...

The royal baby - Australian Women's Weekly
MAKE AWW MY HOMEPAGE SUBSCRIBE AND SAVE TODAY FOOD RECIPES ROYALS CELEBS Home Food Recipe search Recipe collections Meal maker Expert Q & A Cookbooks ...

Envoyer par courriel à un ami - Best Buy Canada
Envoyer par courriel à un ami à Best Buy Canada

Bytes - IT + Developer Community - Connect with IT Pros
Bytes.com is a community for Developers and IT Professionals. Join 414,150 members and discuss topics such as software development, networking, ...

Canonical Splines in WPF and Silverlight
January 22, 2009 New York, N.Y. Windows Forms has two methods named DrawCurve and DrawClosedCurve that draw canonical (aka cardinal) splines. ...

Silverlight Toolkit - Issues
Silverlight Toolkit and Silverlight for Windows Phone Toolkit are a set of Microsoft components for developers.

Delicious
Keep, share, and discover the best of the Web using Delicious, the world's leading social bookmarking service.

DotNetNuke Modules – Anatomy of the View
-*+Now that we’ve laid the foundation of DotNetNuke modules, it is time to start looking at the specific modules. While it would be practically ...

Resources last updated: 12/5/2015 11:19:52 AM