example 'Wizerd' doesn't do the job

2 posts, 1 answers
  1. Mydatafactory
    Mydatafactory avatar
    68 posts
    Member since:
    Feb 2008

    Posted 26 Jun 2008 Link to this post

    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
    1  
    2 Partial Class Project  
    3     Inherits System.Web.UI.UserControl  
    4     Protected Sub nextButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles nextButton.Click  
    5         UpdatePreview()  
    6  
    7         GoToNextTab()  
    8     End Sub  
    9  
    10     Private Sub GoToNextTab()  
    11         Dim tabStrip As RadTabStrip = Page.FindControl("RadTabStrip1")  
    12         Dim FileUploadInfoTab As RadTab = tabStrip.FindTabByText("FileUpload")  
    13         FileUploadInfoTab.Enabled = True 
    14         FileUploadInfoTab.Selected = True 
    15  
    16         GoToNextPageView()  
    17     End Sub  
    18  
    19     Private Sub GoToNextPageView()  
    20         Dim multiPage As RadMultiPage = Page.FindControl("RadMultiPage1")  
    21         Dim FileUploadInfoPageView As RadPageView = multiPage.FindPageViewByID("FileUpload")  
    22         If FileUploadInfoPageView Is Nothing Then  
    23             FileUploadInfoPageView = New RadPageView()  
    24             FileUploadInfoPageView.ID = "FileUpload" 
    25             multiPage.PageViews.Add(FileUploadInfoPageView)  
    26         End If  
    27         FileUploadInfoPageView.Selected = True 
    28     End Sub  
    29  
    30     Private Sub UpdatePreview()  
    31         Dim previewControl As Control = Page.FindControl("previewControl")  
    32  
    33         Dim ProjNameLabelPreview As Label = previewControl.FindControl("lblProjectName")  
    34         ProjNameLabelPreview.Text = txtProjectName.Text  
    35  
    36         Dim ProjDescriptionLabelPreview As Label = previewControl.FindControl("ProjDescriptionLabel")  
    37         ProjDescriptionLabelPreview.Text = txtProjectDescription.Text  
    38  
    39         Dim ReferenceLabelPreview As Label = previewControl.FindControl("ReferenceLabel")  
    40         ReferenceLabelPreview.Text = txtReference.Text  
    41  
    42     End Sub  
    43 End Class  
    44  
    45  

    Preview.ascx
    1 <%@ Control Language="VB" AutoEventWireup="false" CodeFile="PreviewVB.ascx.vb" Inherits="Telerik.Web.Examples.TabStrip.ApplicationScenarios.Wizard.PreviewVB" %> 
    2 <h2> 
    3     Preview:</h2> 
    4 <ul> 
    5     <li style="text-align:left;font-weight:bold;">  
    6         <asp:Label runat="server" ID="lblProjectName"></asp:Label> 
    7     </li> 
    8     <li style="text-align:left;font-weight:bold;">  
    9         <asp:Label runat="server" ID="ProjDescriptionLabel"></asp:Label> 
    10     </li>     
    11     <li style="text-align:left;font-weight:bold;">  
    12           
    13         <asp:Label runat="server" ID="ReferenceLabel"></asp:Label> 
    14     </li> 
    15 </ul> 
    16 <h3> 
    17     Files uploaded  
    18     </h3> 
    19 <ul> 
    20       
    21                             <asp:Label ID="lblNoResults" runat="server" Visible="true">No uploaded files</asp:Label> 
    22                             <asp:Repeater ID="rpvalidResults" runat="server" Visible="false"><HeaderTemplate>Uploaded Files:<br /> 
    23                             </HeaderTemplate> 
    24                             <ItemTemplate> 
    25                             <%#DataBinder.Eval(Container.DataItem, "FileName")%> 
    26                              (<%#DataBinder.Eval(Container.DataItem, "ContentLength").ToString() + " bytes"%><br /><br /> 
    27                              </ItemTemplate></asp:Repeater> 
    28       
    29 </ul> 
    30  
    31  

    default.aspx.vb
    1  
    2 Partial Class Default2  
    3     Inherits System.Web.UI.Page  
    4  
    5  
    6     Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load  
    7         If Not Page.IsPostBack Then  
    8             AddTab("Project", True)  
    9  
    10             Dim pageView As New RadPageView()  
    11             pageView.ID = "Project" 
    12             RadMultiPage1.PageViews.Add(pageView)  
    13  
    14             AddTab("FileUpload", False)  
    15             AddTab("TasksToFile", False)  
    16         End If  
    17     End Sub  
    18  
    19     Private Sub AddTab(ByVal tabName As String, ByVal enabled As Boolean)  
    20         Dim tab As New RadTab(tabName)  
    21         tab.Enabled = enabled 
    22         RadTabStrip1.Tabs.Add(tab)  
    23     End Sub  
    24  
    25     Protected Sub RadMultiPage1_PageViewCreated(ByVal sender As Object, ByVal e As RadMultiPageEventArgs) Handles RadMultiPage1.PageViewCreated  
    26         Dim pageViewContents As Control = LoadControl(e.PageView.ID & ".ascx")  
    27         pageViewContents.ID = e.PageView.ID & "userControl"  
    28  
    29         e.PageView.Controls.Add(pageViewContents)  
    30     End Sub  
    31 End Class  
    32  
    33  

  2. Answer
    Paul
    Admin
    Paul avatar
    4281 posts

    Posted 26 Jun 2008 Link to this post

    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
Back to Top