Button click fires when I refresh page

Posted by SurajRane under ASP.NET on 6/9/2010 | Views : 5187 | Status : [Member] | Replies : 1
I have a button on form.I have implemented button_click event for the button as follows

protected void button_Click(object sender,EventArgs e)
{
//i did following operation

// update salarytbl set salary=salary+1000
}

Here if i click button it will fire click event and update salary say salary is 500 then updated will be 1500

but now when i click refresh button again salary is updated to 2500, again i click refresh salary is 3500.. it goes

ie button click is fired when i say refresh.

why it is happening??




Responses

Posted by: Vuyiswamb on: 6/9/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
in your page load event add the following code

if(!Page.isPostBack)

{

//Do all the operation that was done on page load
}


Thank you for posting at Dotnetfunda
[Administrator]

SurajRane, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response