Ask User To Confirm Browser Navigation

Good afternoon everyone!
I am trying to alert the user if they have unsaved data when they try to close a browser or navigate to another page.
I have written the C# and JavaScript that works when the user interacts with the browser. The problem is that the code fires when the user clicks any control on the .aspx Web page that causes a post back. I only want to alert the user when the user
clicks on the browser, not on the controls on my C# page.
JavaScript Code:
// Javascript for the main Questions.
var ss = "";
window.onload = function () {
//alert("In Window Load");
ss = document.getElementById("KevinsInput");
// This works in IE, FireFox, and Chrome.
// make IE7, IE8 compatible
var myEvent = window.attachEvent || window.addEventListener;
var chkevent = window.attachEvent ? 'onbeforeunload' : 'beforeunload';
// For >=IE7, Chrome, Firefox
myEvent(chkevent, function (e) {
if (ss.value == "1") {
ss.value = "";
} else {
ss.value = "";
var confirmationMessage = 'You have unsaved changes, are you sure you want to leave the page?';
(e || window.event).returnValue = confirmationMessage;
return confirmationMessage;
C# Code
/// <summary>
/// User clicked the button, set the Processed flag.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button1_Click(object sender, EventArgs e)
this.Process.Value = "1";
Thanks for your help.

Hello,
Welcome to MSDN forum.
I am afraid that the issue is out of support range of VS General Question forum which mainly discusses
the usage of Visual Studio IDE such as WPF & SL designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System
and Visual Studio Editor.
 I suggest that you can consult your issue on ASP.NET forum:
http://forums.asp.net/  for better solution and support.
Thanks,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • Express install always asks user to close browser window

    Is Adobe in charge of the code that closes browser windows at
    the end of express install?
    I'm currently using SWFobject 1.5 to embed my flash movie
    with express install active and neither IE6, IE7 or firefox will
    automatically close once express install has finished. It used to
    be that IE would close and reopen the window, firefox never used to
    but that's a different topic I'm sure.
    Perhaps Adobe changed something?

    Never mind, found the answer here:
    Re: Closing brower window

  • Ask User confirmation before droping table

    Hi,
    I need to build a script that ask user a confirmation before that he execute the script that drop a table like "Do you check the log file before droping table Y/N"
    I start to do this but it's not working well, I'm new in sql and PLsql
    accept condition prompt "Do you check all log file (Y/N)"
    DECLARE
    V varchar2(1) := 'N';
    BEGIN
    if &condition=V then
    EXECUTE IMMEDIATE 'drop table t';
    else
    dbms_output.put_line ('please check your log file');
    end if;
    END;
    Regards,

    vittel wrote:
    Hi,
    I need to build a script that ask user a confirmation before that he execute the script that drop a table like "Do you check the log file before droping table Y/N"
    I start to do this but it's not working well, I'm new in sql and PLsql
    accept condition prompt "Do you check all log file (Y/N)"
    DECLARE
    V varchar2(1) := 'N';
    BEGIN
    if &condition=V then
    EXECUTE IMMEDIATE 'drop table t';
    else
    dbms_output.put_line ('please check your log file');
    end if;
    END;
    /if the value of &condition is the single character N, then
    if &condition=V thenwill be sent to the compiler as:
    if N=V thenWhich assumes there is a variable called N.
    I think what you meant was:
    if '&condition' = V thenwhich will be sent to the compiler as
    if 'N' = V thenNote that substitution variables (like &condition) are evaluated and replaced before the PL/SQL code is compiled, so you can use substitution variables in an anonymous block, like you're doing, but you can't use them in a stored procedure to get user input at run-time.

  • Upload file without asking user for the file

    Hi,
    I need to upload a file to server, but from my code, not using the file upload from page.
    I have created a xml file and I need to upload to server when user open a web browser (without asking user to select a file).
    How do I proceed??, or what kind of libraries do I must use?
    thanks

    davisote wrote:
    Hi,
    thanks for answer.
    Let me try to explain again (I think its very simple).Simple, yes. But not very thorough.
    I have developed a web application using JSF.So all the code is running on the server, right? There are no Applets, Applications or WebStart applications involved. Right?
    My application has a splash screen where I show data. I have developed a bean to connect to my database (sql server), extract this data and create an xml (using DOM) file like:
    <news>
    <simplenews id="1"> Value </simplenews>
    </news>And that bean runs ... where? Server again?
    (important step) Once I have created the xml file in my bean I want to upload to the server to a place like /WEB-INF/news.
    If the code is running on the server, then "uploading" is the wrong term, as there's nowhere to upload to, since you're already on the server.
    This may sound like nit-picking, but you're sending us on a wrong trail with this phrase.
    Once the file is on the server with another bean I read the xml fileWhy don't you simply store it in the application scope and let everyone access it from there? It doesn't sound as if the XML is huge.
    As you can see I haven't a web page where to show an upload file componetYou also don't want to "upload" anything from the client, from the sound of it.
    You simply want to transfer data between to server-side components, if I understood you correctly.

  • Best Practice with Browser navigation buttons

    My Web Ap does a secured login and then the user is
    guided to various pages via Command buttons and links.
    The question I have is if the user presses the browser buttons to
    go back the various prior screens appear with waht the user
    entered. I do ot want this.
    What is the best practice to stop this functionality and or capture a event
    that f the user does this the screens are cleared?

    (I believe all Faces page navigation is done via POST (command{Button,Link}).)
    In our app (pre-Faces, but now we're moving to Faces, and I just can't tell you how much fun it is grafting Faces onto an old JSP/servlet app), we chose to open a new window when the user logs in, without browser decorations (i.e., navigation buttons). (This is done via javascript window.open(), with the appropriate options.)
    The old window can't be closed due to Javascript security constraints, so we redirect it to another page so the user won't be confused if he or she stumbles across what looks like a login page (by exposing that old window).
    After that, it's mostly an effort in user education: we just don't tell them about things like alt-left-arrow to go back or F5 to refresh or right-click anything (except View Source when we're debugging a problem). If they're "smart", we tell them "Don't do that", where "that" is either "stick your finger in your eye" or "use alt-left-arrow", depending on your sense of humor and ability to parse my idiomatic English.
    [There's an old joke in which a man goes to a doctor and says "Doctor, my eye hurts".  The doctor says "Hmm, can you tell me more?"  The patient says "Yes, it hurts when I do [i]this," and proceeds to jab his finger into his eye. The doctor says, "Ah, I see. Well, don't that any more," and the patient walks away satisfied with his "cure."]
    John.

  • Publishing Catalyst: browser navigation/seo questions

    How do you enable the browser navigation so a user can return to the previous page or move forward with the browser buttons. Also, the url is the same for each page. I have a project with multiple pages and I would like to make each page contain a specific link like xyz.com/home (when on the home page) and xyz.com/pictures (when in the gallery), etc... that way I can make external links to specific content on my site.
    Also, I am concerned as to how the seo will turn out with my catalyst site. Do you have a simple example as to how I will be able to include my site in an organic search. Excuse my lack of knowledge in this area. Any information as to how I will be able utilize seo with my catalyst project is much appreciated!
    Lastly, what is the best way to increase the intial loading speed of my site?

    I'll try to answer some of these.
    As for loading, you will want to make sure all the images are linked and elements not used on a state are removed (not just turned invisible). Peter Flynn's session on Flash Catalyst at the 2010 Adobe MAX conference covered this. You can view it on tv.adobe.com (MAX 2010 Design - Mastering Flash Catalyst | Adobe TV)
    Adobe has worked with all the major search engines to provide methods to allow the content in the SWF to be indexed. Here is an article on it (SEO | Adobe Developer Connection)
    As for browser history management, you are going to have to add this to your project using Flash Builder. Here is some information on it: http://oreilly.com/flash/excerpts/seo-for-flash/understanding-browsermanager-class.html
    Hope this gets you started.
    Chris

  • How can I disable Firefox asking me to confirm a resend when I hit BACK button?

    When I hit the back key after doing a search and clicking on a result, Firefox usually, but not always, asks me to confirm resending before taking me back. This is very annoying. I can't find any option to disable this.
    Is there some way to disable this, or can I suggest it as an enhancement? When I click on BACK, I just want it to go back without prompting me to confirm it.

    '''In url:'''
    about:config
    '''find:'''
    browser.sessionstore.postdata
    '''change:'''
    0 to 1
    Got this from a buddy, been working fine so far.
    OS: Ubuntu 10.04
    Browser: FF 3.6.18

  • How to ask user to enter value in select statement

    Hi,
    Can anyone tell me syntax of select statement where i can ask user to enter value .
    for example i am trying to use belowthing but it displaying error
    select * from emp where empname=:empname
    SP2-0552: Bind variable "empname" not declared.
    2.Is there any data dictionary table to see all pl/sql procedures and corresponding code?
    Thanks,
    sri

    user632733 wrote:
    Can anyone tell me syntax of select statement where i can ask user to enter value .None. The SQL engine resides on the server. It is incapable of prompting for data entry on the client.
    The client interacts with the user. The client is suppose to:
    a) prompt for variable values
    b) send a SQL statement to Oracle
    c) bind values to bind variables in the SQL statement
    for example i am trying to use belowthing but it displaying error
    select * from emp where empname=:empnameIn SQL*Plus, you need to create a bind variable:
    SQL> var empname varchar2(200)
    And then assign a value to it:
    SQL> exec :empname := 'John Doe';
    Note that this is still not ideal - as the assignment is also done via the server and sends a PL block to the server. This block contains non-sharable code and this can lead to fragmentation of the server's Shared Pool.
    But it does illustrate the basic principle.

  • Why does iPhoto keep asking me to confirm faces after they are already confirmed?

    Why does iPhoto keep asking me to confirm faces after they are already confirmed?
    Once it searches for photos containing (insert name) and says "(insert name) maybe found in 1,750 photos". I click to confirm the said person and it highlights the photos already found in that persons "folder", which already contains 662 photos AND it does not show any of the unconfirmed photos. However, it told me that it found 1,750 photos....where are the missing unconfirmed pictures for me to tag? I have already rebuilt my thumbnails (which already took 3 days to do as I have MANY photos).

    You are running Firefox 34, the most recent version is 35.0.1. If you are having trouble updating, please try downloading the most recent version from www.getfirefox.com and installing it over your existing version. It will save your information but update Firefox to the newest version.

  • Dont want to allow user to confirm more hours than planned hours

    Hi,
    in the projects,
    we dont want to allow user to confirm more hours than planned hours.
    Pls suggest.
    Thanks

    txn OPST
    set confirmation parameters with work and duration deviation  = 0
    set up std workflow for work/ duration deviation
    if anyone does ignore the warning and continues with the confirmation at least you will get a message
    this is std SAP no development is needed

  • How to get the online user  who are browse some view?

    i want to get the current users who are browsing some view in EP6.additonal:which is developed as web dynpro project.

    Hi,
    Per my knowledge, we cannot get the SharePoint user context available in custom federated search connector with other methods.
    Here is a similar thread for your reference:
    https://answers.atlassian.com/questions/263735/atlassian-sharepoint-connector-federated-search-authentication-and-authorization
    Thanks,
    Linda Li                
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Linda Li
    TechNet Community Support

  • Change Behaviour of the 4 Browse / Navigation Buttons

    Hi!,
    In documents, Iam using a new series each period/month for each type of documents, for example for a quote document in october, the series was named 200810 , for november, the series was named 200811 and so on. So each time a new period/month pases, my DocNum, starts again from 1. This gives me great control in my numbering system, but I get an inconvinience when using the 4 browse/navigation buttons, becuase If I click the last record button, it gives me the document with the biggest DocNum. Not the actual last record.
    Please Help!
    Thank you!

    Please note: when you get something very convenient, chances are you are also get some by-products that may not be that convenient.
    Unfortunately, you have to type in the number to find if this number is not in the current series selection.  Another way will be making sure the number series is the right one to get the max number for that series.  In another word, you can only have one last record which will match your current series selection.
    Thanks,
    Gordon

  • Picture and text for anonymous user: picture is asking user id and password

    Hi all,
    I created one html page in KM. In that one picture and some text is there.
    Given anonymous user & group permission for picture and html..
    created one KM document Iview given the path.
    Iview is assigned to Page,  Page to role(Given anonymous authorization for iview and page) and  Role is assigned to anonymous group.
    when I see the preview its asking user/pwd for Picture not for text. If I discord pic is not displaying....
    How to display Pic and text in one page, how to maintain the permissions
    Thanks
    Polaka

    Hello Polaka,
    You need to carefully go through all the recommendations from SAP note 837898 and make sure you have followed everything in the note exactly, most anonymous issues are caused when this note is not correctly implemented.
    Regarding permissions, you should give your anonymous users at least read permissions on the picture which is being used as well as on the html file itself.
    Regards,
    Lorcan.

  • Open tab or window in user's default browser

    hi,
    can I navigate to a url and open a new window or tab in the user's  default browser?
    In flex panels - if you'd
    navigateToURL(new URLRequest("url.com"));
    the page would open up in the user's default browser.
    How to do this in an html panel?
    When I try 
    window.open("url.com '_blank');
    a custom window opens and I'm not even sure where it comes from,
    my default  browser or the extension's embedded browser.
    Thanks!
    Jeff.

    var csInterface = new CSInterface(); 
    csInterface.openURLInDefaultBrowser('http://www.google.com');

  • How can I invalide the session automatically while user close IE browser

    I have tried to add onUnload function to javascript, but it seems it doesn't call when user close the browser. Anyone could offer me suggestions?

    Crosspost: http://forum.java.sun.com/thread.jspa?threadID=5179905

Maybe you are looking for

  • Geforce 210 + windows 8.1 = death ?

    Estimate HP team: Im facing a very rare problem with my video card My computer is this: http://h20564.www2.hp.com/hpsc/doc/public/display?​docId=emr_na-c03517270 windows 8.1 and my video card is this: http://www.gigabyte.com/products/product-page.asp

  • Cant display jsp using Tomcat and xml

    Anybody out there can help me solve this problem??? I cant display the table... The error came out like dis : org.apache.jasper.JasperException: This absolute uri (http://jakarta.apache.org/taglibs/xtags-1.0) cannot be resolved in either web.xml or t

  • Help! How to Download Existing Website into DW8?

    Anybody got a simple 4-step formula to do this?  The support team for my IP/server doesn't have any idea of how to do it? I need a complete file for DW8 so I can edit existing site. Current server has lost all of my files? Got to switch to new server

  • Drawing a Line Series

    I am relatively new to flex charting and was wondering if there was a way to somehow make the curve lineseries draw from left to right. I am using an array collection as the data provider and obtaining the values from a text file. Any help would be g

  • Select in xsql not executed

    Hello, i have a file employee1.xsql: <?xml version='1.0'?> <xsql:query xmlns:xsql="urn:oracle-xsql" connection="employee" rowset-element="OK" row-element="EMPLOYEE"> SELECT employee_id "ID" ,last_name "NAME" ,job_id "JOB" ,salary "SALARY" ,commission