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
  1. Home
  2. Web Development
  3. ASP.NET
  4. Submit changes from a form back to a database

Submit changes from a form back to a database

Scheduled Pinned Locked Moved ASP.NET
databasesysadminquestionannouncement
3 Posts 2 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
    ASPnoob
    wrote on last edited by
    #1

    Hello all, I have a form that allows users to enter data and a button users can click to send data to the database. To ensure that data are sent to the database if and only if the form is modified, is it enough to use the statement if(!page.ispostback) in the button Onclick event in the codebehind page to check if the page is being sent to the server? Aside from the code to connect to a database then update or insert data, is there something else I would have to do? Thanks in advance.

    H 2 Replies Last reply
    0
    • A ASPnoob

      Hello all, I have a form that allows users to enter data and a button users can click to send data to the database. To ensure that data are sent to the database if and only if the form is modified, is it enough to use the statement if(!page.ispostback) in the button Onclick event in the codebehind page to check if the page is being sent to the server? Aside from the code to connect to a database then update or insert data, is there something else I would have to do? Thanks in advance.

      H Offline
      H Offline
      Homero Rivera
      wrote on last edited by
      #2

      I hope this helps: A page will be a postback if a user submits something (either by click or any other mechanism) and you use the same page C# / VB after what triggered the submision. Therefore, using a button on a form will cause it to be a postback, and the if (!IsPostback... will enter into effect, preventing you to get to the desired code. If you want to prevent a user from clicking the same button or triggering the same mechanism, at the end of your code you can disable the button with something as Button1.Enabled = false; which is the most common I've seen. That way, the user won't be able to make a second change with that particular button.

      1 Reply Last reply
      0
      • A ASPnoob

        Hello all, I have a form that allows users to enter data and a button users can click to send data to the database. To ensure that data are sent to the database if and only if the form is modified, is it enough to use the statement if(!page.ispostback) in the button Onclick event in the codebehind page to check if the page is being sent to the server? Aside from the code to connect to a database then update or insert data, is there something else I would have to do? Thanks in advance.

        H Offline
        H Offline
        Homero Rivera
        wrote on last edited by
        #3

        No, that will not help. In fact, it will prevent you from submiting the data on the first attempt if it is enclosed by the if "(!IsPostBack".

        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