Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. To warn about the data changes.

To warn about the data changes.

Scheduled Pinned Locked Moved ASP.NET
csharpquestionasp-nettools
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aecordoba
    wrote on last edited by
    #1

    Hi! I'm newbie in ASP.NET world. My question is: I have a web page (ASP.NET 2.0 with code behind file C#) with some controls, like text boxes, drop down lists and so on. I'd like when an user change any data in any control, and then he/she try to close the browswer or try to leave the web page without save the data, it appear a message box warning that he/she will lose the changes. Note: Script options doesn't work because I'm using master pages and scripts can't be inserted in content file. So I need a code-behind solution. Do you have any idea? Thank you in advance.

    -- [Adrián Córdoba]

    P V 2 Replies Last reply
    0
    • A aecordoba

      Hi! I'm newbie in ASP.NET world. My question is: I have a web page (ASP.NET 2.0 with code behind file C#) with some controls, like text boxes, drop down lists and so on. I'd like when an user change any data in any control, and then he/she try to close the browswer or try to leave the web page without save the data, it appear a message box warning that he/she will lose the changes. Note: Script options doesn't work because I'm using master pages and scripts can't be inserted in content file. So I need a code-behind solution. Do you have any idea? Thank you in advance.

      -- [Adrián Córdoba]

      P Offline
      P Offline
      Parwej Ahamad
      wrote on last edited by
      #2

      (1) As per my perception, we can use scripts in Content page. Suppose that you have written few methods in js file called "myjs.js" and then you can access all methods in content page. First add this file in master page like below tag:

      (2) Script is only a way that we can handle achieve your requirement

      < body onbeforeunload="alert('Closing');">

      this is strait way that you shows alert on browser close event. (3) If wants that if something change on your page, then in that case you need to set flag in cookies and with option two (onbeforeunload) event we can check whether something is change or not and then on the basis of that show the alert message.

      Parwej Ahamad R & D with IIS 5.0/6.0

      1 Reply Last reply
      0
      • A aecordoba

        Hi! I'm newbie in ASP.NET world. My question is: I have a web page (ASP.NET 2.0 with code behind file C#) with some controls, like text boxes, drop down lists and so on. I'd like when an user change any data in any control, and then he/she try to close the browswer or try to leave the web page without save the data, it appear a message box warning that he/she will lose the changes. Note: Script options doesn't work because I'm using master pages and scripts can't be inserted in content file. So I need a code-behind solution. Do you have any idea? Thank you in advance.

        -- [Adrián Córdoba]

        V Offline
        V Offline
        Vasudevan Deepak Kumar
        wrote on last edited by
        #3

        Would this help you? www.4guysfromrolla.com/webtech/100604-1.shtml[^]

        Vasudevan Deepak Kumar Personal Homepage
        Tech Gossips
        All the world's a stage, And all the men and women merely players. They have their exits and their entrances; And one man in his time plays many parts... --William Shakespeare

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups