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. Detecting changes on a page

Detecting changes on a page

Scheduled Pinned Locked Moved ASP.NET
databasequestion
7 Posts 3 Posters 2 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.
  • D Offline
    D Offline
    dptalt
    wrote on last edited by
    #1

    I can I detect if any textbox text values have changed before I commit the changes to the database?

    B Y 2 Replies Last reply
    0
    • D dptalt

      I can I detect if any textbox text values have changed before I commit the changes to the database?

      B Offline
      B Offline
      binarymax
      wrote on last edited by
      #2

      In Javascript you can compare the object's "value" property with its "defaultValue" property. Alternatively on the server you can have an object that has the value set on Page_Load or similar, and then on Postback you can compare whats in the Textbox with what your object's value is.

      D 1 Reply Last reply
      0
      • B binarymax

        In Javascript you can compare the object's "value" property with its "defaultValue" property. Alternatively on the server you can have an object that has the value set on Page_Load or similar, and then on Postback you can compare whats in the Textbox with what your object's value is.

        D Offline
        D Offline
        dptalt
        wrote on last edited by
        #3

        Which method is the preferred way of doing it and the least taxing on the server? I have 30 textboxes on the page.

        B 1 Reply Last reply
        0
        • D dptalt

          Which method is the preferred way of doing it and the least taxing on the server? I have 30 textboxes on the page.

          B Offline
          B Offline
          binarymax
          wrote on last edited by
          #4

          Well I dont know enough about your situation to make that call. You could even do it at the database level if you are using stored procedures, but in most cases thats probably not a good idea. Also what are you trying to accomplish specifically? If you dont want the user changing stuff why not just make the fields readonly? If you have a specific reason why not and in a situation where you are already loading data from a database during a request, keeping it in a session object, and then showing that data to a user in a textbox, then on postback you will already have that data on your server and won't need to go back to the database to do your comparison, the original data is already there on the server. Personally I think it would be best practice to check it on the server. Since either way you are going to be testing equality on some field (be it a string or a changed-flag). Are you validating any other fields on the page with javascript? Then you could lump your comparison in there with the validation, but then you'd need to create hidden fields and it might be too complex and not worth the small performance gain you would get when substituting a string compare with the changed field bool. Sorry for rambling :)

          D 1 Reply Last reply
          0
          • B binarymax

            Well I dont know enough about your situation to make that call. You could even do it at the database level if you are using stored procedures, but in most cases thats probably not a good idea. Also what are you trying to accomplish specifically? If you dont want the user changing stuff why not just make the fields readonly? If you have a specific reason why not and in a situation where you are already loading data from a database during a request, keeping it in a session object, and then showing that data to a user in a textbox, then on postback you will already have that data on your server and won't need to go back to the database to do your comparison, the original data is already there on the server. Personally I think it would be best practice to check it on the server. Since either way you are going to be testing equality on some field (be it a string or a changed-flag). Are you validating any other fields on the page with javascript? Then you could lump your comparison in there with the validation, but then you'd need to create hidden fields and it might be too complex and not worth the small performance gain you would get when substituting a string compare with the changed field bool. Sorry for rambling :)

            D Offline
            D Offline
            dptalt
            wrote on last edited by
            #5

            The senerio I have is pretty simple. If the user makes any changes to the data in the textboxes on the page the logic that updates the database needs to update one of the table fields with a 0 otherwise use the existing value. Hence, I need to check if any changes were made on the page. From what I have read using a session varable to store datatable rows is a server resource hog so instead I requery the database each time I need to. And no I am not validating fields on the page with javajscript. Instead I have a class method to do the validating. So to check if a user changed data on the page I should use some javascript?

            B 1 Reply Last reply
            0
            • D dptalt

              The senerio I have is pretty simple. If the user makes any changes to the data in the textboxes on the page the logic that updates the database needs to update one of the table fields with a 0 otherwise use the existing value. Hence, I need to check if any changes were made on the page. From what I have read using a session varable to store datatable rows is a server resource hog so instead I requery the database each time I need to. And no I am not validating fields on the page with javajscript. Instead I have a class method to do the validating. So to check if a user changed data on the page I should use some javascript?

              B Offline
              B Offline
              binarymax
              wrote on last edited by
              #6

              If storing the data in a session is a problem for you then JavaScript will work, yes. Hope I've helped with your problem!

              1 Reply Last reply
              0
              • D dptalt

                I can I detect if any textbox text values have changed before I commit the changes to the database?

                Y Offline
                Y Offline
                Yusuf
                wrote on last edited by
                #7

                What kind of change are we talking about? Do any of the validation controls help you?

                Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]

                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