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

Find Dynamic Control clientSide

1 Answer 45 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Randy
Top achievements
Rank 1
Randy asked on 22 Sep 2008, 02:12 PM
Not sure if there is a way to do this, but here is what I am trying to do.  I am creating Grids Dynamically and I need to find in using an OnClientClick event.  the Button that control fires that is also being created Dynamically.  If there a way to pass the javascript function the info it need to find the grid so I can control it using the clientsdie API?

Thanks

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 24 Sep 2008, 02:05 PM
Hello Ryan Campbell,

Try the following code to retrieve the grid in a global javascript variable:

protected void Page_Load(object sender, EventArgs e)  
{  
    string script = "<script type='text/javascript'>window.onload = " 
        + "function(){setTimeout(function(){var grid = $find('" 
        + RadGrid1.ClientID + "');}, 200);}</script>";  
    Page.RegisterStartupScript("key", script);  

Then you can access the grid object as shown below:

<script type="text/javascript">  
function ClientClick()  
{  
   alert(grid);  
}  
</script>  
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="ClientClick()" /> 

Give it a try and let me know if this works for you.

Best wishes,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Randy
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or