2 Replies - 959 Views - Last Post: 31 July 2014 - 08:32 AM

#1 elegant  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 31-July 14

Click Event Updates database show changes on load?

Posted 31 July 2014 - 08:16 AM

Hi,

I have a web form with a few group boxes and a button. When the button is clicked it calls an event handler which then updates the status of the database record. What is supposed to happen is that now the status of the record is updated it will show and hide the group boxes depending on that status of the record. The problem is the order of things in ASP.NET as page load is run then the click handler. I'm finding when you click the button the page load event is frist called which then gets the original record from the database and is then not changing as it thinks the record is stil the same. After the load has run it then runs the click handler and updates the database. It would be easier if the click handler happened before the load event. Is there anyway to get around this problem?

The ideas for solutions I've come up with are:-
  • After click handler is run refresh the page
  • Use javascript to call a web method that updates the record and then when it finishes do a postback


Thanks For the help, Richard

Is This A Good Question/Topic? 0
  • +

Replies To: Click Event Updates database show changes on load?

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9392
  • View blog
  • Posts: 35,273
  • Joined: 12-June 08

Re: Click Event Updates database show changes on load?

Posted 31 July 2014 - 08:25 AM

Think about how the webform is operating.. it the client clicks, the page has to run to the server to notify, and the server swings around to do a postback. You can deal with having data stay in a session variable and only doing specific loads when not a postback.

  If Not IsPostBack Then

Was This Post Helpful? 0
  • +
  • -

#3 elegant  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 31-July 14

Re: Click Event Updates database show changes on load?

Posted 31 July 2014 - 08:32 AM

I'm not quite spotting how
If Not IsPostBack Then

In the page load would work for me?

The click handler is only changing the status column and based upon the status of the record I want to hide and show div panels, but when I get the record on page load it has not changed as the click handler has not been run yet?

Thanks, Richard
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1