Search code examples
asp.netwebformstelerik-grid

Disable control while post back is happening


I'm working with a telerik grid made in a user control, inside this control there is a checkbox

<telerik:GridTemplateColumn>
    <ItemTemplate>
        <asp:CheckBox ID="check" AutoPostBack="true" runat="server" OnCheckedChanged="check_CheckedChanged"/>
    </ItemTemplate>
</telerik:GridTemplateColumn>

What I need to do is while the "check_CheckedChanged" is happening disable a certain button that is outside the user control (i know this defeats the purpose of the control being independent but that's not something I can change now). This is because the check_CheckedChanged takes too long to execute (as it does a lot of validations) and the user can press the button before its disabled by the result of check_CheckedChanged. By the way, I do have the buttons id in the control if that's info someone needs.


Solution

  • A less than ideal situation, as you've pointed out, but you could use Javascript. In the check_CheckedChanged, write out a Javascript call to a hideButton() function, which is outside of the user control.

    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "script", "hideButton();", true);