This is a migrated thread and some comments may be shown as answers.

How to find RadGrid in usercontrol from .aspx page

1 Answer 110 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Salman
Top achievements
Rank 1
Salman asked on 19 Nov 2013, 11:47 AM
Hello...

I have a Radgrid inside user control & I want to find it from aspx page server side. I have written the following code for it but shows me error $find()...is null....

Can anyone please help me asap?

Usercontrol.ascx

function RadGridRow() {
     return $find("<%=RGOrders.ClientID %>").get_masterTableView().get_dataItems();
}

Page.aspx

function abc() {
     var RgOrders = RadGridRow();
}

Please note that I am calling the function abc() from server-side (code - behind). From client side, this function is working fine

Page.aspx.cs

string strscript = "abc();";
ScriptManager.RegisterStartupScript(pnl, pnl.GetType(), "ShowMessage" + DateTime.Now.ToLongTimeString(), strScript, true);

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 20 Nov 2013, 04:02 AM
Hi Salman,

Please have a look into the following code snippet to call a client side function from the server side and access the RadGrid in UserControl From the ASPX page.

ASPX C#:
protected void Page_Load(object sender, EventArgs e)
{
    //call the client side function of the aspx page
    string script = "function f(){abc(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);  
}

ASPX JavaScript:
<script type="text/javascript">
    function abc() {
        var RgOrders = RadGridRow();
    }
</script>

ASCX JavaScript:
<script type="text/javascript">
    function RadGridRow() {
        return $find("<%=RadGrid1.ClientID %>").get_masterTableView().get_dataItems();
    }
</script>

Thanks,
Shinu.
Tags
General Discussions
Asked by
Salman
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or