i have a radtoolbar in user control page which is telerik control i want to access its child elements i already add usercontrol on panel control have id panel1 now i want to access radtoolbar child elements using javascript helpppppppppppp
i have a radtoolbar in user control page which is telerik control i want to access its child elements i already add usercontrol on panel control have id panel1 now i want to access radtoolbar child elements using javascript helpppppppppppp
the correct way to access Telerik controls is to use the client side API that all telerik controls provide.
Here is what i did to achive a solution for your problem
1. created a UserControl similar to what you have in the problem statement. One change i did was to add ClientIDMode property to the RadToolBar. Here is my definition of the RadToolbar:
With ClientIDMode what happens is - the APS.NET pipeline will create the ID as is what you have mentioned in the ID property. So you will need to make sure that the ID is unique in the page. In my case i have given the ID as "MenuStyleRadToolBar1".
2. In Default.aspx page, i have included the user control as below:
First we add a register tag and then include the user control.
3. add Page load event to the body and write the page load javascript function as below:
<body onload="Page_Load()">
<script>
function Page_Load() {
var toolBar = $find("MenuStyleRadToolBar1");
}
</script>
As you see Telerik controls provide a $find() method on the client side. So i am just passing the control name to $find() and it will fetch the control.
Here is the documentation of the RadTollBar client side API. once you have the object, you can perform any operation on that following the API functions exposed.
mahsan12
Member
28 Points
38 Posts
How to get the chilld user control values
Apr 04, 2012 10:34 AM|LINK
i have added usercontrol in a panel on content page now i want to access the panel child controls by using javascript
this is my user control page
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MenuStyle1.ascx.cs" Inherits="ERP.WebForms.MenuStyle1" ClassName="MenuStyle1" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<telerik:RadToolBar ID="RadToolBar1" Runat="server"
EnableRoundedCorners="True" EnableShadows="True" Width="940px"
onbuttonclick="RadToolBar1_ButtonClick" onunload="RadToolBar1_Disposed">
<Items>
<telerik:RadToolBarButton CommandName="btn" Text="Add" ImageUrl="../Images/Add.png"
ImagePosition="AboveText" />
<telerik:RadToolBarButton Text="Update" ImageUrl="../Images/Edit.png" ImagePosition="AboveText" />
<telerik:RadToolBarButton Text="Delete" ImageUrl="../Images/Delete.png"
ImagePosition="AboveText" />
<telerik:RadToolBarButton Text="Refresh" ImageUrl="../Images/Refresh.png" ImagePosition="AboveText" />
<telerik:RadToolBarButton Text="Print" ImageUrl="../Images/Print.png"
ImagePosition="AboveText" Enabled="False" />
<telerik:RadToolBarButton Text="Close" ImageUrl="../Images/Close.png"
ImagePosition="AboveText" />
<telerik:RadToolBarButton Text="Save As" ImageUrl="../Images/SaveAs.png"
ImagePosition="AboveText" />
<telerik:RadToolBarButton Text="Itemtemplate">
<ItemTemplate>
<div id="loginAarea" style="margin-left:150px" >
<table style="margin-left: -50px;" >
<tr>
<td >
<telerik:RadTextBox ID="txtUserName" runat="server" Label="Added By"
Width="240" Height="16" Enabled="false" Font-Bold="True" ></telerik:RadTextBox>
</td>
<td>
<telerik:RadTextBox ID="txtLastUserName" runat="server"
Label="Last Updated By" Width="240" Height="16" Enabled="false"
Font-Bold="True" ></telerik:RadTextBox>
</td>
</tr>
<tr>
<td>
<telerik:RadTextBox ID="txtLoginDate" runat="server" Label="Date:"
Width="240" Height="16" Enabled="false" Font-Bold="True" ></telerik:RadTextBox>
</td>
<td>
<telerik:RadTextBox ID="txtLastLoginDate" runat="server" Label="Date:"
Width="240" Height="16" Enabled="false" Font-Bold="True" ></telerik:RadTextBox>
</td>
</tr>
</table>
</div>
</ItemTemplate>
</telerik:RadToolBarButton>
</Items>
</telerik:RadToolBar>
and this is the cotent page code where i add user control on panel
<script runat="server">
private ASP.MenuStyle1 Spinner1;
protected void Page_Load(object sender, EventArgs e)
{
Page.LoadControl("MenuStyle1.ascx");
Spinner1 = (ASP.MenuStyle1)LoadControl("MenuStyle1.ascx");
rad.Controls.Add(Spinner1);
Panel1.Controls.Add(Spinner1);
pane.Controls.Add(Spinner1);
}
</script>
now i want to access telerik:RadToolBarButton of user control by using javascript how i do help?????????????
mahsan12
Member
28 Points
38 Posts
Re: How to get the chilld user control values
Apr 04, 2012 10:48 AM|LINK
i have a radtoolbar in user control page which is telerik control i want to access its child elements i already add usercontrol on panel control have id panel1 now i want to access radtoolbar child elements using javascript helpppppppppppp
mahsan12
Member
28 Points
38 Posts
Re: How to get the chilld user control values
Apr 04, 2012 10:48 AM|LINK
i have a radtoolbar in user control page which is telerik control i want to access its child elements i already add usercontrol on panel control have id panel1 now i want to access radtoolbar child elements using javascript helpppppppppppp
sriramabi
Contributor
4351 Points
1277 Posts
Re: How to get the chilld user control values
Apr 04, 2012 10:52 AM|LINK
hi
http://sureshsharmaaspdotnet.wordpress.com/2008/11/20/find-usercontrol-field-from-aspx-pages/
http://www.codeproject.com/Tips/110836/How-to-get-Value-from-from-usercontrol-to-aspx-pag
thank u
kashyapa
Member
81 Points
25 Posts
Re: How to get the chilld user control values
Feb 01, 2013 06:23 AM|LINK
Hi
the correct way to access Telerik controls is to use the client side API that all telerik controls provide.
Here is what i did to achive a solution for your problem
1. created a UserControl similar to what you have in the problem statement. One change i did was to add ClientIDMode property to the RadToolBar. Here is my definition of the RadToolbar:
<telerik:RadToolBar ID="MenuStyleRadToolBar1" ClientIDMode="Static" runat="server" EnableRoundedCorners="True" EnableShadows="True" Width="940px">With ClientIDMode what happens is - the APS.NET pipeline will create the ID as is what you have mentioned in the ID property. So you will need to make sure that the ID is unique in the page. In my case i have given the ID as "MenuStyleRadToolBar1".
2. In Default.aspx page, i have included the user control as below:
<%@ Register Src="~/MenuStyle.ascx" TagPrefix="uc1" TagName="MenuStyle" %> <div> <uc1:MenuStyle runat="server" id="MenuStyle" /> </div>First we add a register tag and then include the user control.
3. add Page load event to the body and write the page load javascript function as below:
<body onload="Page_Load()"> <script> function Page_Load() { var toolBar = $find("MenuStyleRadToolBar1"); } </script>As you see Telerik controls provide a $find() method on the client side. So i am just passing the control name to $find() and it will fetch the control.
Here is the documentation of the RadTollBar client side API. once you have the object, you can perform any operation on that following the API functions exposed.
http://www.telerik.com/help/aspnet-ajax/toolbar-client-side-basics.html
Hope this helps.
http://about.me/kashyapa