Wednesday, March 21, 2012

Problem in RowCommand event of GridView within UpdatePanel

I have GridView and its EditItemTemplate has TextBox and in other column ImageButton.

I do defaultbutton this my ImageButton.

protected void GridView1_PreRender(object sender, EventArgs e)
{
GridViewRow editRow = (GridViewRow)this.GridView1.Rows[this.GridView1.EditIndex];

ImageButton imgBtnSave = editRow.FindControl("imgBtnSave")as ImageButton;

this.PanelGrid.DefaultButton = imgBtnSave.UniqueID;

}

my GridView1 is within panel - PanelGrid.

Before AJAX all worked very good. But in AJAX I have problem: in IE in textbox Enter works once only, in Firefox Enter don't work quite.

I did as they advised me:

I did function on JS:

function beforeDefaultClick( btnDefault )
{
__defaultFired = false;

btnDefault.disabled = true;

__doPostBack( btnDefault.name,'' );
}

For my ImageButton I write: OnClientClick="beforeDefaultClick( this )"

And now in IE all works good, but in Firefox event RowCommand of my GridView works twice !

I don't know how resolve this problem. Help me please.

Hi Alg42,

ALG42:

OnClientClick="beforeDefaultClick( this )"

Based on my experience, you should use OnClientClick="beforeDefaultClick( this ); return false;" instead.

Best regards,

Jonathan


Thank you.This works ! Smile

No comments:

Post a Comment