I have Save button as part of EditItemTemplate
of the grid. on click of the button I want to disable the button to have a single click disable effect.
- I did try with javascript, in this case no server side code is executed.
- Added the attribute to the button, even this doesn't help
- Tried by adding
UseSubmitBehavior="false"
property too
Wh开发者_运维技巧at would be other possible solution to achieve this?
(Answered by in a question edit. Converted to a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )
The OP wrote:
Here is the solution:
Set the
UseSubmitBehavior="false"
for the button inaspx
page.In the
.c
s page, in theRowDataBound
event write the following code:
///Grid row event RowDataBound
protected void gvr_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if ((e.Row.RowState & DataControlRowState.Edit) > 0)
{
///Creating the Save button object
Button btn = (Button)e.Row.Cells[6].FindControl("btnSave");
///Add the attribute to disblae the button
btn.Attributes.Add("onclick", "this.disabled=true;");
}
}
}
精彩评论