Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
216 views
Please run this in your environment, an ASPX page loading two UserControls Dynamically. The second UserControl adds Tabs via client code. Press the Click buttons on Tab2.

Could someone tell me what is wrong and why the nested Tabs will not work?

Thanks

Content Page
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="NestedTabDynamicUC.aspx.cs" Inherits="NestedTabDynamicUC_NestedTabDynamicUC" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title>NestedTabDynamicUC</title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
     
    <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
    <telerik:RadAjaxManager ID="RadAjaxManagerMaster" runat="server"> 
    </telerik:RadAjaxManager> 
     
    <div> 
    <asp:Label ID="lblMessage" runat="server" /> 
        <telerik:RadTabStrip Visible="true" BorderStyle="Solid" BorderColor="black" BorderWidth="0px"   
        ID="RadTabStrip1" runat="server" Skin="Outlook" SelectedIndex="0" AutoPostBack="true"  
        OnTabClick="RadTabStrip1_TabClick"> 
        <Tabs> 
            <telerik:RadTab Text="Tab 1" ID="tab0" runat="server"></telerik:RadTab> 
            <telerik:RadTab Text="Tab 2" ID="tab1" runat="server"></telerik:RadTab> 
        </Tabs> 
    </telerik:RadTabStrip> 
     
    <asp:Panel ID="pnlControls" runat="server" style="padding:5px 1px 2px 5px;" /> 
     
     
    </div> 
     
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server"> 
<AjaxSettings> 
             
    <telerik:AjaxSetting AjaxControlID="RadTabStrip1"> 
        <UpdatedControls> 
            <telerik:AjaxUpdatedControl ControlID="RadTabStrip1" /> 
            <telerik:AjaxUpdatedControl ControlID="pnlControls" LoadingPanelID="RadAjaxLoadingPanel1" /> 
            <telerik:AjaxUpdatedControl ControlID="lblMessage" /> 
        </UpdatedControls> 
    </telerik:AjaxSetting> 
     
             
</AjaxSettings> 
</telerik:RadAjaxManagerProxy> 
 
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Transparency="30" BackColor="#E0E0E0"> 
    <asp:Image ID="Image1" ImageUrl="~/Images/Loading7.gif" BorderWidth="0px" AlternateText="Loading"  
    runat="server" Style="margin-top: 45px;" /> 
</telerik:RadAjaxLoadingPanel> 
 
 
    </form> 
</body> 
</html> 
 

Content Page Code Behind
using System; 
using System.Collections; 
using System.Configuration; 
using System.Data; 
using System.Web; 
using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.HtmlControls; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
 
public partial class NestedTabDynamicUC_NestedTabDynamicUC : System.Web.UI.Page 
{ 
    #region Properties 
 
    private string LatestLoadedControlName 
    { 
        get { return (string)ViewState["LatestLoadedControlName"]; } 
        set { ViewState["LatestLoadedControlName"] = value; } 
    } 
    #endregion 
    #region Page Events 
 
    protected void Page_Load(object sender, EventArgs e) 
    { 
        if (LatestLoadedControlName != null) 
        { 
            LoadUserControl(LatestLoadedControlName); 
        } 
        else 
        { 
            LoadUserControl("WebUserControl.ascx"); 
        } 
    }  
    #endregion 
    #region Tabs Events 
 
    protected void RadTabStrip1_TabClick(object sender, Telerik.Web.UI.RadTabStripEventArgs e) 
    { 
        lblMessage.Text = e.Tab.Text + " " + e.Tab.SelectedIndex.ToString() + " " + e.Tab.ID; 
 
        switch (e.Tab.ID.ToUpper()) 
        { 
            case "I0": 
                LoadUserControl("WebUserControl.ascx"); 
                break; 
            case "I1": 
                LoadUserControl("WebUserControl2.ascx"); 
                break; 
            default: 
                LoadUserControl("WebUserControl.ascx"); 
                break; 
        } 
 
    } 
 
    private void LoadUserControl(string controlName) 
    { 
        if (LatestLoadedControlName != null) 
        { 
            Control previousControl = pnlControls.FindControl(LatestLoadedControlName.Split('.')[0]); 
            if (!Object.Equals(previousControl, null)) 
            { 
                this.pnlControls.Controls.Remove(previousControl); 
            } 
        } 
        string userControlID = controlName.Split('.')[0]; 
        Control targetControl = pnlControls.FindControl(userControlID); 
        if (Object.Equals(targetControl, null)) 
        { 
            UserControl userControl = (UserControl)this.LoadControl(controlName); 
            //slashes and tildes are forbidden 
            userControl.ID = userControlID.Replace("/", "").Replace("~", ""); 
            this.pnlControls.Controls.Add(userControl); 
            LatestLoadedControlName = controlName; 
        } 
    }  
    #endregion 
} 
 

WebUserControl.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="NestedTabDynamicUC_WebUserControl" %> 
User Control 1 
<br /> 
<telerik:radcodeblock ID="RadCodeBlock2" runat="server"> 
    <%=System.DateTime.Now.ToString() %> 
</telerik:radcodeblock> 

WebUserControl2.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl2.ascx.cs" Inherits="NestedTabDynamicUC_WebUserControl2" %> 
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> 
<script type="text/javascript"> 
 
function addNewTab() 
{     
    //Adds the tab to the Tabs Collection of the selected tab 
    var persistChanges = true; 
     
    var tabStrip = $find("<%= RadTabStrip1.ClientID %>"); 
    var mymultiPage = $find('<%= RadMultiPage1.ClientID %>'); 
     
    var tabCount = tabStrip.get_tabs().get_count(); 
    // Check if we have already opened the Tab 
    for (i = 0; i< tabCount; i++) { 
        var tab2 = tabStrip.get_tabs().getTab(i); 
        if (tab2 != null) { 
            if (tab2.get_text() == "Tab Id " + arguments[0].toString()) { 
                tab2.select(); 
                return false; 
            } 
        } 
    } 
     
    var selectedTab = tabStrip.get_selectedTab(); 
    var test = arguments[0]; 
     
    if (persistChanges) { 
        tabStrip.trackChanges(); 
        mymultiPage.trackChanges(); 
    }        
    var tab = new Telerik.Web.UI.RadTab(); 
    tabStrip.get_tabs().add(tab);    
    tab.set_text("Tab Id " + arguments[0].toString()); 
    tab.select(); 
         
    var pageView = new Telerik.Web.UI.RadPageView();     
    mymultiPage.get_pageViews().add(pageView); 
     
    pageView.get_element().innerHTML = "Page content here " + arguments[0].toString(); 
     
    pageView.set_selected(true);     
     
    if (persistChanges) { 
        tabStrip.commitChanges(); 
        mymultiPage.commitChanges();  
    } 
    return false;       
} 
 
</script> 
</telerik:RadCodeBlock> 
 
<ul> 
    <li>Load Tab 21&nbsp;<input type="button" value="Click" onclick="return addNewTab('1');" /></li> 
    <li>Load Tab 22&nbsp;<input type="button" value="Click" onclick="return addNewTab('2');" /></li> 
</ul> 
 
<hr style="width:1px;" /> 
 
<telerik:RadTabStrip runat="server" ID="RadTabStrip1" Skin="Outlook" Style="float:left"  
            SelectedIndex="0" CssClass="tabStrip" MultiPageID="RadMultiPage1"> 
            </telerik:RadTabStrip> 
             
            <telerik:RadMultiPage ID="RadMultiPage1" runat="server" CssClass="multiPage" 
            BorderStyle="Solid"  
            BorderWidth="1px"  
            BorderColor="#999999">             
            </telerik:RadMultiPage> 
             
 
             

Officialboss
Top achievements
Rank 1
 answered on 09 Jun 2008
8 answers
385 views
"invalid json primitive: undefined" pops up in IE when I start my web app.

I have isolated it to a single control inside a sliding panel.  On this control if I set height and width both to 100%, I do not get the error message.  If I instead set height and width to something fixed like 300px, then I get the message.  The control is third party, ESRI ArcGIS Server Map control.

My page is a simple nested splitter design. 

If I create a new page just a splitter, and two panels, one with the map control, then I do not get the error.

How do you even begin to troublshoot "invalid json primitive: undefined" popup problem?




Shawn
Top achievements
Rank 1
 answered on 09 Jun 2008
5 answers
123 views
When I insert new code block I could set its height and width properties, but how I could later change them?

Thnx.
Rumen
Telerik team
 answered on 09 Jun 2008
2 answers
421 views

I have installed RadEditor on WSS with complete success.  The only thing that bothers me is that when viewing list pages through Firefox, a link stating "Click for help about adding basic HTML formatting" is placed below each RadEditor box.  Any ideas on how to remove those links? 

Thanks!

Charles
Top achievements
Rank 1
 answered on 09 Jun 2008
1 answer
113 views
I am maintaining/extending an asp.net ajax app that basically uses the scriptmanager, updatepanel, and updateprogress components.
I am planning on gradually rolling in some Telerik rad ajax controls soon.
Should I go through the project and first replace the scriptmanager, updatepanel, and updateprogress components with the rad ajax equivalents, e.g.,
RadScriptManager, Rad???, and RadAjaxLoadingPanel (Rad??? = I don't know what the equivalent control would be - can't tell by the "rad..." name).
Is this a valid assumption on my part?
I have not had any luck in my search for documentation on this subject.  If there is some, please provide a link or specific search keyword string.  Most of the code snippets I have looked at are just that, snippets, and with these controls being totally new to me, there does not seem to be a simple "start here...".
My cursory attempts have not been successful, for example, I added a RadAjaxLoadingPanel control to a page, added a thread.sleep(3000) to the page_load(), and I do not see any "loading..." message on the web page.
Thanks for your direction to a complete newbie on Telerik controls.
Erjan Gavalji
Telerik team
 answered on 09 Jun 2008
2 answers
228 views
hi ,
        Is it possible to Enable / disable  Context menu items on tree view item right click from Javascript.


Thanks,

Vinod


            
Veselin Vasilev
Telerik team
 answered on 09 Jun 2008
1 answer
163 views
I'm making something similar to this example--
http://www.telerik.com/demos/aspnet/prometheus/Panelbar/Examples/ApplicationScenarios/OutlookNavigation/DefaultCS.aspx

In the ASPX:

<telerik:RadTreeView ID="RadTreeView1" runat="server" MultipleSelect="True" Skin="Office2007" Height="213px" OnLoad="OnTreeLoad">
</telerik:RadTreeView>

In the C#:
 protected void OnTreeLoad(object sender, System.EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            RadTreeView tree = (RadTreeView)sender;
            tree.LoadContentFile("xml/app_config.xml");
        }
    }

In the XML:
<?xml version="1.0" encoding="utf-8" ?>
<PanelItems>
</PanelItems>


This generates an error which comes from inside the treeview code:

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
Telerik.WebControls.RadTreeViewXmlParser.LoadFromXmlElement(XmlElement parentNodeElement, RadTreeNodeCollection nodeCollection, Int32 level) +29
Telerik.WebControls.RadTreeViewXmlParser.LoadFromXml(String xmlString) +106
Telerik.WebControls.RadTreeView.LoadContentFile(String path) +143
MasterPage.OnTreeLoad(Object sender, EventArgs e) in c:\adminui\MasterPage.master.cs:47
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.WebControls.DataBoundControl.OnLoad(EventArgs e) +46
Telerik.WebControls.RadTreeView.OnLoad(EventArgs e) +37
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436

Ed Bassin
Top achievements
Rank 1
 answered on 09 Jun 2008
4 answers
253 views
Hello,

is there an issue with horizontal scrolling in a PanelBar ItemTemplate? Vertical scrolling works fine. I have a TreeView inside the template, but the horizontal scrollbar does not appear when the TreeView is expanded.

I found the same issue at: http://www.telerik.com/community/forums/thread/b311D-edhac.aspx

Greetings
Philip
Andreas Kaech
Top achievements
Rank 1
 answered on 09 Jun 2008
1 answer
169 views
I load my Radcombobox with Load on Demand. This works great.

Now, i have to set the selected value in the code behind.

Should i implement again an search query for finding the index for selecting ?

which is the best method for that ?

I have to set something like that:

radcombobox.selectedindex = 4 ??
Veselin Vasilev
Telerik team
 answered on 09 Jun 2008
5 answers
157 views
We are currently on RadControls for ASP.NET 2007 Q1 and are planning a migration to RadControls for ASP.NET AJAX in the near future and were wondering if the '_wrapper' spans were still used as a wrapper in the new version.  We've found a use for setting the css class of the wrapper and would like to make sure this is still viable in the new version before we fully implement it.

Thank you,

Jim
Rosi
Telerik team
 answered on 09 Jun 2008
Narrow your results
Selected tags
Tags
+? more
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?