What i'm trying to do is place a specific chart that is dynamically created on a specific tab. For example Chart A will go to ColorTab and Chart B will go to HistoryTab
<telerik:RadAjaxPanel ID="StripPanel" runat="server" Width="100%">
<telerik:RadTabStrip ID="TabStrip" runat="server" MultiPageID="Monetary" SelectedIndex="0">
<Tabs>
<telerik:RadTab Text="MonetaryTab">
</telerik:RadTab>
<telerik:RadTab Text="VTab">
</telerik:RadTab>
<telerik:RadTab Text="ColorTab">
</telerik:RadTab>
<telerik:RadTab Text="HistoryTab">
</telerik:RadTab>
<telerik:RadTab Text="AdTab">
</telerik:RadTab>
</Tabs>
</telerik:RadTabStrip>
</telerik:RadAjaxPanel>
This is what i'm trying
Control masterC = FindControl("MonetaryTab");
RadHtmlChart CarLotChart = ChartCreationClass.HTMLChartCreation();
masterC.Controls.Add(CarLotChart);
It never finds the control to place the chart.
Use recommendations from this thread to accomplish this task:
RadHtmlChart CarLotChart = ChartCreationClass.HTMLChartCreation();
TabStrip.Tabs["MonetaryTab"].Controls.Add(CarLotChart);
Refer to the required Tab via any of the following methods.
The RadTabStrip works in conjuction with RadmultiPage control. You first define the RafTabStrip and Tabs within it. Then have a RadMultiPage and define one page (type RadPageView) for each tab you have defined in TabStrip. The controls need to be added to the PageView and not to the tab directly.
I have created a small demo based on the TabStrip you have defined in the question.
Here is the TabStrip code:
<telerik:RadTabStrip ID="TabStrip" runat="server" MultiPageID="Monetary" SelectedIndex="0" >
<Tabs>
<telerik:RadTab Text="MonetaryTab">
</telerik:RadTab>
<telerik:RadTab Text="VTab">
</telerik:RadTab>
<telerik:RadTab Text="ColorTab">
</telerik:RadTab>
<telerik:RadTab Text="HistoryTab">
</telerik:RadTab>
<telerik:RadTab Text="AdTab">
</telerik:RadTab>
</Tabs>
</telerik:RadTabStrip>
Now here is the RadMultiPage definition:
<telerik:RadMultiPage ID="Monetary" runat="server" SelectedIndex="0" OnLoad="Monetary_Load">
<telerik:RadPageView runat="server" ID="monetaryTabPageView"/>
<telerik:RadPageView runat="server" ID="vTabPageView"/>
<telerik:RadPageView runat="server" ID="colorTabPageView"/>
<telerik:RadPageView runat="server" ID="historyTabPageView"/>
<telerik:RadPageView runat="server" ID="adTabPageView"/>
</telerik:RadMultiPage>
Notice that i am listening to OnLoad event of the RadMultiPage. In this demo - when the RadMultiPage loads, i will create charts and add it to eacg pageview we have. Here is the event handler code:
protected void Monetary_Load(object sender, EventArgs e)
{
AddChart(monetaryTabPageView);
AddChart(vTabPageView);
AddChart(colorTabPageView);
AddChart(historyTabPageView);
AddChart(adTabPageView);
}
private void AddChart(RadPageView pageView)
{
RadHtmlChart chart = new RadHtmlChart();
chart.ChartTitle.Text = pageView.ID + " chart";
pageView.Controls.Add(chart);
}
As you can see i just add the control directly to the pageview's controls collection.
NOTE: as a proof of concept i have created an empty chart i.e. a chart which has only title defined. you can go ahead and bind with some meaningful data if required.
here is the screenshot of how this looks:
Hope this answers your question.
Lohith (Tech Evangelist, Telerik India)
Related
I'm using Telerik (for ASP.NET AJAX) RadMultiPage controls to produce nested tabs and I would like to link to a specific tab from another page. But I couldn't find a proper way.
Here is my code
<telerik:RadTabStrip runat="server" ID="RadTabStrip1" MultiPageID="RadMultiPage1" SelectedIndex="0">
<Tabs>
<telerik:RadTab Text="ParentTab1"></telerik:RadTab>
<telerik:RadTab Text="ParentTab2"></telerik:RadTab>
</Tabs>
</telerik:RadTabStrip>
<telerik:RadMultiPage runat="server" ID="RadMultiPage1" SelectedIndex="0">
<telerik:RadPageView ID="ParentTab1" runat="server" >
<telerik:RadTabStrip runat="server" ID="RadTabStrip2" MultiPageID="RadMultiPage2" SelectedIndex="0">
<Tabs>
<telerik:RadTab Text="ChildTab1"></telerik:RadTab>
<telerik:RadTab Text="ChildTab2"></telerik:RadTab>
</Tabs>
</telerik:RadTabStrip>
<telerik:RadMultiPage ID="RadMultiPage2" SelectedIndex="0" runat=server>
<telerik:RadPageView ID="ChildTab1" runat="server">
<%--ChildTab1 Content--%>
</telerik:RadPageView>
<telerik:RadPageView ID="ChildTab2" runat="server" >
<%--ChildTab2 Content--%>
</telerik:RadPageView>
</telerik:RadMultiPage>
</telerik:RadPageView>
</telerik:RadMultiPage>
And it looks like:
The question is how could I insert a link exactly points to "ChildTab2" into another page.
The quick answer is "You can't".
The tabs are simple HTML and JavaScript, when you click a tab, the display of the PageViews is switched, that's all. These are not anchors that you can switch to.
What you can consider is adding a querystring parameter that you can work with in the code-behind and set the selected tab as desired.
Of course, you can do this on the client, but accessing the controls may be a tad harder, and so is parsing the URL (whether it is a querystring or a hash).
i am facing problem with telerik tab control.
i have two tabs which i have created using telerik tab control that is radtabstrip.
now i have one dropdownlist control which is inside radpageview of radmultipage.
now can any one provide me syntax of how to access drop downlist which is inside radpageview of
radmultipage???
i have tried this but facing error:
radpageview1.drodownlist1.item.selecteditem;
You need to use FindControl() like with any other nested control (e.g., a Panel). Here is an example:
protected void Page_Load(object sender, EventArgs e)
{
RadDropDownList rddl = RadPageView2.FindControl("RadDropDownList1") as RadDropDownList;
rddl.Visible = false;
}
assuming your structure looks like this (whether it is generated from the code-behind is irrelevant, you only need to recreate it early enough):
<telerik:RadTabStrip runat="server" ID="RadTabStrip1" MultiPageID="RadMultiPage1">
<Tabs>
<telerik:RadTab Text="first"></telerik:RadTab>
<telerik:RadTab Text="second"></telerik:RadTab>
</Tabs>
</telerik:RadTabStrip>
<telerik:RadMultiPage runat="server" ID="RadMultiPage1">
<telerik:RadPageView ID="RadPageView1" runat="server" Width="100%">
PageView
</telerik:RadPageView>
<telerik:RadPageView ID="RadPageView2" runat="server" Width="100%">
<telerik:RadDropDownList runat="server" ID="RadDropDownList1"></telerik:RadDropDownList>
</telerik:RadPageView>
</telerik:RadMultiPage>
Does a RadTabStrip work in a MasterPage? The tabs do not appear selected when clicked.
Steps:
Create a new Web Application Project. By default it contains Home and About tabs inside a Master Page (Site.Master). The tabs are asp:MenuItem controls.
Comment out the asp:Menu control and drag a RadTabStrip in its place. Add two RadTabs. When you run the application each tab works as expected -- it appears to be selected when clicked.
Now add NavigateUrls to each RadTab pointing to the "~Default.aspx" and "~About.aspx" pages. When the application runs the tabs don't appear to be selected when clicked (although the correct page displays).
What's going on? How can I make this work?
Update: Here's how I altered the default code in Site.Master...
<div>
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
</div>
<%--<div class="clear hideSkiplink">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
<Items>
<asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home"/>
<asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/>
</Items>
</asp:Menu>
</div>--%>
<div>
<telerik:RadTabStrip ID="RadTabStrip1" runat="server">
<Tabs>
<telerik:RadTab runat="server" Text="Root RadTab1" NavigateUrl="~/Default.aspx">
</telerik:RadTab>
<telerik:RadTab runat="server" Text="Root RadTab2" NavigateUrl="~/About.aspx" >
</telerik:RadTab>
</Tabs>
</telerik:RadTabStrip>
</div>
The answer...
Bojan Skrchevski's answer led me to this. I added this code to the Master Page's Page_Load event and it works:
using Telerik.Web.UI;
namespace WebApplication1
{
public partial class SiteMaster : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
RadTab currentTab = RadTabStrip1.FindTabByUrl(Request.Url.PathAndQuery);
if (currentTab != null) currentTab.Selected = true;
}
}
}
I think that you also need to add runat="server" to the RadTab element if you want to use it like that. For example:
<telerik:RadTab Text="Home" NavigateUrl="Default.aspx" runat="server">
</telerik:RadTab>
You can also use ContentUrl in the corresponding telerik:RadPageView to navigate on the client side. Example:
<telerik:RadPageView ID="RadPageView1" runat="server" ContentUrl="Default.aspx">
UPDATE(on your update):
When you add runat="server" to the RadTab then it causes a postback. On postback the control is unable to determine which tab is selected even though it navigates to the specified page. Here's how it is solved in the Telerik example:
protected void Page_Load(object sender, System.EventArgs e)
{
string urlWithSessionID = Response.ApplyAppPathModifier(Request.Url.PathAndQuery);
RadTab tab = RadTabStrip1.FindTabByUrl(urlWithSessionID);
if (tab != null)
{
tab.SelectParents();
tab.PageView.Selected = true;
}
}
The only difference I can see in your code compared to my master page is SelectedIndex="0" on the RadTabStrip and Selected="true" on one of the Rad Tabs:
<telerik:RadTabStrip ID="RadTabStrip1" runat="server" SelectedIndex="0">
<Tabs>
<telerik:RadTab runat="server" Text="Root RadTab1" NavigateUrl="~/Default.aspx" Selected="true">
</telerik:RadTab>
<telerik:RadTab runat="server" Text="Root RadTab2" NavigateUrl="~/About.aspx" >
</telerik:RadTab>
</Tabs>
</telerik:RadTabStrip>
Code
<telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1" OnTabClick="RadTabScript1_TabClick" OnClientTabSelecting="onTabSelecting" > <%-- OnClientTabSelecting="onTabSelecting"> --%>
<Tabs>
<telerik:RadTab Text="Resources" runat="server" TabIndex="0" Selected="true" PageViewID="radPageResources"></telerik:RadTab>
<telerik:RadTab Text="Tasks" runat="server" TabIndex="1" PageViewID="radPageTasks"></telerik:RadTab>
<telerik:RadTab Text="Messages" runat="server" TabIndex="2" PageViewID="radPageMessages"></telerik:RadTab>
<telerik:RadTab Text="Files" runat="server" TabIndex="3" PageViewID="radPageFiles"></telerik:RadTab>
<telerik:RadTab Text="Feedback" runat="server" TabIndex="4" PageViewID="radPageFeedback"></telerik:RadTab>
</Tabs>
</telerik:RadTabStrip>
<telerik:RadMultiPage ID="RadMultiPage1" runat="server" OnPageViewCreated="RadMultiPage1_PageViewCreated" SelectedIndex="0" > <%-- RenderSelectedPageOnly="true" > --%>
<telerik:RadPageView ID="radPageResources" runat="server" TabIndex="0">
<telerik:RadGrid runat="server" ID="grdResource" PageSize="5" Skin="Default" AllowPaging="True"
AllowSorting="true" ShowFooter="true" AutoGenerateColumns="False" Width="97%"
OnItemCreated="grdResource_ItemCreated" OnNeedDataSource="grdResource_NeedDataSource"
OnDeleteCommand="grdResource_DeleteCommand" ShowStatusBar="True" GridLines="None"
OnItemDataBound="grdResource_ItemDataBound">
</telerik:RadGrid>
Like this i have 4 pageview tabs with indexes and every pageview tab contains a grid.If suppose i did changes in some x-grid and causes postback,then i need the x-grid should be shown after the postback. But i was showing the Resourcegrid.
codebehind
protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)
{
RadMultiPage1.SelectedIndex = e.PageView.TabIndex;
}
but this event not firing in any case.
so how can i come back to the previous grid even when postback occurs?
try set selected index in page_prerender.
protected void Page_PreRender(object sender, EventArgs e)
{
//RadTab t1 = new RadTab();
//RadMultiPage m1 = new RadMultiPage();
m1.SelectedIndex = t1.SelectedIndex;
}
i don't know my solution can be helpful for this subject or not
I tried all methods and finally find myself method,
i suggest if your problem not solved make java script function and then call it from code behind
My Sample :
function OnClientClick1(i) {
var tabstrip1 = $find("<%=RadTabStrip1.ClientID %>");
tabstrip1.set_selectedIndex(1);
}
and then make function on your code to call that
private void ChangeTab(int index)
{
string scriptyKey = "Alert" + Guid.NewGuid().ToString().Replace("-", "_");
ScriptManager.RegisterStartupScript(Page, Page.GetType(), scriptyKey, "OnClientClick1("+index.ToString()+");", true);
}
I hope be useful
I am using Telerik RadTab controls. I have taken three tabs.
In my application in RadioButtonList I have three radio buttons, if I click the REPLACEMENt radio button it will show next tab ADTAF
<telerik:RadTabStrip ID="RadTabStrip1" runat="server" Skin="Inox" MultiPageID="RadMultiPage1"
SelectedIndex="0" Height="16px" Width="710px">
<Tabs>
<telerik:RadTab Text="Purchase Details" Selected="True">
</telerik:RadTab>
<telerik:RadTab Text="CERF">
</telerik:RadTab>
<telerik:RadTab Text="ADTAF">
</telerik:RadTab>
</Tabs>
</telerik:RadTabStrip>
<asp:RadioButtonList ID="radiobtnlistcerf" runat="server" Width="300px"
Height="40px" onselectedindexchanged="radiobtnlistcerf_SelectedIndexChanged">
<asp:ListItem>New addition</asp:ListItem>
<asp:ListItem>Replacement</asp:ListItem>
<asp:ListItem>Addition to main asset</asp:ListItem>
</asp:RadioButtonList>
How to show next tab if I click on Replacement radio button?
Your question isn't exactly clear, but I think you mean that you want it to show 'CERF' next instead of 'ADTAF', in which case you would need to increment the selected tab index. If you wanted it to go through the tabs in order you could do something like:
RadTabStrip1.SelectedIndex = (RadTabStrip1.SelectedIndex + 1)%(RadTabStrip1.Tabs.Count)
Maybe if you showed the code for radiobtnlistcerf_SelectedIndexChanged it would be clearer why its not working