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

Poblem on Dynamic create RadMultiPage & RadTabStrip

0 Answers 107 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Wilson
Top achievements
Rank 1
Wilson asked on 08 Sep 2008, 05:37 PM
Hi,

I need to create RadTabStrip and RadMultiPage in code-behind, and put them into a PlaceHolder.  However, I got the  "Microsoft JScript runtime error: Sys.ArgumentException: Value must not be null for Controls and Behaviors.
Parameter name: element" error.

It is ok if I declare the RadMultiPage in aspx page,  but failed if I cratead it on-the-fly.

Please help.

Rdgs,
Wilson

Here's the aspx code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="RadTabTest.aspx.vb" Inherits="RadTabTest" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>
<%
@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!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>Untitled Page</title>
</head>
<
body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager id="ScriptManager1" runat="server">
</asp:ScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
</telerik:RadAjaxManager>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
</div>
<
/form>
</
body>
</
html>

Here's the RadTabTest.aspx.vb code:

Partial Class RadTabTest
    Inherits System.Web.UI.Page
    Dim WithEvents oTabStrip As RadTabStrip
    Dim WithEvents oMultiPage As RadMultiPage

     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        oTabStrip = New RadTabStrip
        oMultiPage = New RadMultiPage

        oTabStrip.Attributes.Add("runat", "server")

        AddTab(oTabStrip, oMultiPage, "Corporate")
        AddTab(oTabStrip, oMultiPage, "Personal")
        AddTab(oTabStrip, oMultiPage, "Personal22")

        oTabStrip.MultiPageID = oMultiPage.ID

        PlaceHolder1.Controls.Add(oTabStrip)
        PlaceHolder1.Controls.Add(oMultiPage)

    End Sub

    Private Sub AddTab(ByVal oTabStrip As RadTabStrip, ByVal oMultiPage As RadMultiPage, ByVal tabName As String, Optional ByVal bSelected As Boolean = False)

        Dim oPage As New RadPageView
        oPage.ID = tabName

        Dim oLabel As New Label
        oLabel.ID = "Label." + tabName
        oLabel.Text = tabName
        oPage.Controls.Add(oLabel)

        Dim oTab As New RadTab
        oTab.Text = tabName
        oTab.Attributes.Add("runat", "server")
        oTab.PageViewID = oPage.ID

        If bSelected Then
            oTab.Selected = True
        End If
        oTabStrip.Tabs.Add(oTab)

        oMultiPage.PageViews.Add(oPage)

    End Sub

    Protected Sub oTabStrip_TabClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTabStripEventArgs) Handles oTabStrip.TabClick

        e.Tab.PageView.Selected = True
        e.Tab.Selected = True

    End Sub

End Class

No answers yet. Maybe you can help?

Tags
TabStrip
Asked by
Wilson
Top achievements
Rank 1
Share this question
or