2014年7月13日 星期日

[RESOLVED] ASP.Net ImageButton not firing onclick


ASP.Net ImageButton not firing onclick


Hi there, I've this error when clicked in ImageButton, can you help me?

Thank you in advance. 


Invalid postback or callback argument.  Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback
or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.






Width="50px" Height="50px" Style="cursor: pointer" OnClick="Button_OnClick" />



    protected void Button_OnClick(object sender, EventArgs e)
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "btn", "");
}









Are you manipulating server-side controls in your javascript?





AidyF



Are you manipulating server-side controls in your javascript?





not sir ...



Set <%@ Page EnableEventValidation="false" %>

protected void Button_OnClick(object sender, ImageClickEventArgs e)
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "btn", "");
}



Hi,


If you are binding the grid view in page load, make sure you are binding the gridview like given below.


protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bindGridView();
}
}






沒有留言:

張貼留言