Link to home
Start Free TrialLog in
Avatar of Sam T
Sam T

asked on

Button needs to be clicked twice to trigger btnSaveEvent() in VB.net

I have a form on web application, I load the field values on the form and click the save button and it doesn't save the record on the database at first click but if I press the button again it saves it. I put the breakpoint on my Page_Load()event and tried debugging it so what happens is as I run the application, Page_Load() gets executed populates the data on the grid. Now, if I enter field values and click save, it again goes to Page_Load() event but it doesn't go to button_save() event. But if I click it again then it goes to Page_Load() and then goes to button_Save() and saves the record.

I want to click the mouse button once and save the record, how could I be able to do that? I am using VB.NET. Thank you.
Avatar of Arana (G.P.)
Arana (G.P.)

See if removing the Javascript ONCLICK properties helps it trigger at the first time.
Also when you edit the grid does it postback the data? or does it trigger a grid.changed event?
when you edit grid and then click save button the textbox loses focus and  might be triggering other events instead of the save button
Avatar of Sam T

ASKER

I removed the ONCLICK Properties from Javascript still does the same thing

User generated image
I put the field values on the text box and click the save. It goes to form_load() event but it doesn't call the btnSave() event. But on the next Save Click it goes to form_load()event and then goes to btnSave()event and display the grid result like shown above. 
are you using a jfavascript button or a web form button?
It shouldn't be reloading the page the button_click event shuld be fireing
Avatar of Sam T

ASKER

Thanks David, that is what I am expecting it should not reload the page but when I put the break point in the form_load() event every time I save button the first thing it does is it loads the page and during the second click it again calls Page_Load() and then goes to btnSave_Click().  Below is the btnSave_Click() event

User generated image
Protected WithEvents btnSave As Global.System.Web.UI.WebControls.Button


Open in new window


ASKER CERTIFIED SOLUTION
Avatar of Sam T
Sam T

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Exactly what I was trying to get at with my previous comment, but you never answered it.
textchanged event was interfering with the click event,  

This is what I was trying to say in above answer, hence asking if it was postingback but  you did not answer, and if you had events after editing the grid,
 but I guess I didnt explain well enough.