Search code examples
javascriptasp.netuser-controlsdevexpressaspxgridview

How to use javascript to find ASPxGridView in Usercontrol and then command it to perform callback?


I have created Usercontrol called Attach_Template and I assigned its ID as "attachTemplate" in the master page as follows:

<uc1:Attach_Template ID="attachTemplate" runat="server" />

In my usercontrol, there is ASPxGridview with ID = "gv_Attach" and ClinetInstanceName = "grid". I want to write a function to perform callback to this ASPxGridView from Master page.

I've tried the following code. It seems that it could find the control but cannot do perform callback.

<script type="text/javascript">
    function gvAttachPerformCallback() {
        var gvAttach = document.getElementById('<%=Attach_Template.FindControl("gv_Attach").ClientID%>');
        gvAttach.PerformCallback(null);
    }
</script>

The following error message occured when I tried to perform callback.

Error: Object doesn't support property or method 'PerformCallback'


Solution

  • You should use ClientInstanceName to access control on client side. Then call clientInstanceName.PerformCallback(), or in your case grid.PerformCallback().