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

example 'Wizerd' doesn't do the job

1 Answer 78 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Mydatafactory
Top achievements
Rank 1
Mydatafactory asked on 26 Jun 2008, 02:03 PM
I try to rebuild the example of 'wizard'  but I get the error on line 33: Object reference not set to an instance of an object. I checked the code, but I can't find the solution.

Project.ascx.VB
 
Partial Class Project  
    Inherits System.Web.UI.UserControl  
    Protected Sub nextButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles nextButton.Click  
        UpdatePreview()  
 
        GoToNextTab()  
    End Sub  
 
    Private Sub GoToNextTab()  
        Dim tabStrip As RadTabStrip = Page.FindControl("RadTabStrip1")  
        Dim FileUploadInfoTab As RadTab = tabStrip.FindTabByText("FileUpload")  
        FileUploadInfoTab.Enabled = True 
        FileUploadInfoTab.Selected = True 
 
        GoToNextPageView()  
    End Sub  
 
    Private Sub GoToNextPageView()  
        Dim multiPage As RadMultiPage = Page.FindControl("RadMultiPage1")  
        Dim FileUploadInfoPageView As RadPageView = multiPage.FindPageViewByID("FileUpload")  
        If FileUploadInfoPageView Is Nothing Then  
            FileUploadInfoPageView = New RadPageView()  
            FileUploadInfoPageView.ID = "FileUpload" 
            multiPage.PageViews.Add(FileUploadInfoPageView)  
        End If  
        FileUploadInfoPageView.Selected = True 
    End Sub  
 
    Private Sub UpdatePreview()  
        Dim previewControl As Control = Page.FindControl("previewControl")  
 
        Dim ProjNameLabelPreview As Label = previewControl.FindControl("lblProjectName")  
        ProjNameLabelPreview.Text = txtProjectName.Text  
 
        Dim ProjDescriptionLabelPreview As Label = previewControl.FindControl("ProjDescriptionLabel")  
        ProjDescriptionLabelPreview.Text = txtProjectDescription.Text  
 
        Dim ReferenceLabelPreview As Label = previewControl.FindControl("ReferenceLabel")  
        ReferenceLabelPreview.Text = txtReference.Text  
 
    End Sub  
End Class  
 
 

Preview.ascx
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="PreviewVB.ascx.vb" Inherits="Telerik.Web.Examples.TabStrip.ApplicationScenarios.Wizard.PreviewVB" %> 
<h2> 
    Preview:</h2> 
<ul> 
    <li style="text-align:left;font-weight:bold;">  
        <asp:Label runat="server" ID="lblProjectName"></asp:Label> 
    </li> 
    <li style="text-align:left;font-weight:bold;">  
        <asp:Label runat="server" ID="ProjDescriptionLabel"></asp:Label> 
    </li>     
    <li style="text-align:left;font-weight:bold;">  
          
        <asp:Label runat="server" ID="ReferenceLabel"></asp:Label> 
    </li> 
</ul> 
<h3> 
    Files uploaded  
    </h3> 
<ul> 
      
                            <asp:Label ID="lblNoResults" runat="server" Visible="true">No uploaded files</asp:Label> 
                            <asp:Repeater ID="rpvalidResults" runat="server" Visible="false"><HeaderTemplate>Uploaded Files:<br /> 
                            </HeaderTemplate> 
                            <ItemTemplate> 
                            <%#DataBinder.Eval(Container.DataItem, "FileName")%> 
                             (<%#DataBinder.Eval(Container.DataItem, "ContentLength").ToString() + " bytes"%><br /><br /> 
                             </ItemTemplate></asp:Repeater> 
      
</ul> 
 
 

default.aspx.vb
 
Partial Class Default2  
    Inherits System.Web.UI.Page  
 
 
    Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load  
        If Not Page.IsPostBack Then  
            AddTab("Project", True)  
 
            Dim pageView As New RadPageView()  
            pageView.ID = "Project" 
            RadMultiPage1.PageViews.Add(pageView)  
 
            AddTab("FileUpload", False)  
            AddTab("TasksToFile", False)  
        End If  
    End Sub  
 
    Private Sub AddTab(ByVal tabName As String, ByVal enabled As Boolean)  
        Dim tab As New RadTab(tabName)  
        tab.Enabled = enabled 
        RadTabStrip1.Tabs.Add(tab)  
    End Sub  
 
    Protected Sub RadMultiPage1_PageViewCreated(ByVal sender As Object, ByVal e As RadMultiPageEventArgs) Handles RadMultiPage1.PageViewCreated  
        Dim pageViewContents As Control = LoadControl(e.PageView.ID & ".ascx")  
        pageViewContents.ID = e.PageView.ID & "userControl"  
 
        e.PageView.Controls.Add(pageViewContents)  
    End Sub  
End Class  
 
 

1 Answer, 1 is accepted

Sort by
0
Accepted
Paul
Telerik team
answered on 26 Jun 2008, 02:25 PM
Hello A.,

The FindControl method provides you with a reference to any control. You must make sure that you properly typecast the returned value as FindControl returns a reference to a Control class. For detailed information on the subject please make a search in MSDN.

On aside note, the provided information does not help us much in reproducing the error. I'm afraid we could not be of much help unless we reproduce the issue on our side. It will be best if you can open a support ticket and send us a simple running project (incl. your custom skin, CSS, images, DB backup if needed and so on) demonstrating the problem (and step-by-step instructions on doing so). In that way we can reproduce and pinpoint the problems you're facing on our side, understand the logic of your application and provide a solution.

Regards,
Paul
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
TabStrip
Asked by
Mydatafactory
Top achievements
Rank 1
Answers by
Paul
Telerik team
Share this question
or