Event Not Firing For Button

Posted by Vijayar under C# on 8/11/2011 | Points: 10 | Views : 4518 | Status : [Member] | Replies : 4
Hi
I am using image save button,and i writing code for save ,byt the event is not geting fired

<asp:ImageButton ID="btnsave" runat="server" ImageUrl="sub_btn.png"
OnClick="btnsave_Click" Width="100px" Height="35px" />

protected void btnsave_Click(object sender, CommandEventArgs e)
{

if (e.CommandName == "update")
{
UpdateOrNewRecord(true);
}
else
{
UpdateOrNewRecord(false);
}


}

public void UpdateOrNewRecord(bool isupdate)
{

//

}

when i click on save .its not getting fired.Please tell me reason

vijaya


Responses

Posted by: Dhirendra on: 8/11/2011 [Member] Starter | Points: 25

Up
0
Down
your event handler method does not match with delegate 'System.Web.UI.ImageClickEventHandler'
and you should not able to see the page itself.
here is the correct aspx code which you need to put
aspx

<asp:ImageButton CommandName="Update" OnCommand="btnsave_Click" ID="btnsave" runat="server" Width="100px"
Height="35px" />





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

Posted by: Mcadeepuraj on: 8/12/2011 [Member] Starter | Points: 25

Up
0
Down
Change This line and no need to write if e.CommandName == "update"
protected void btnsave_Click(object sender, ImageClickEventArgs e)
{

}

Deepak Kumar

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

Posted by: Kunalverma31 on: 8/16/2011 [Member] Starter | Points: 25

Up
0
Down
try using command event in image button i.e ImageButton1_Command(object sender, CommandEventArgs e)

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

Posted by: Kunalverma31 on: 8/16/2011 [Member] Starter | Points: 25

Up
0
Down
try using command event in image button i.e ImageButton1_Command(object sender, CommandEventArgs e)

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

Login to post response