NullReferenceException in the Xhtml.cs

4 posts, 0 answers
  1. Binu
    Binu avatar
    2 posts
    Member since:
    Apr 2008

    Posted 07 May 2008 Link to this post

    I am generating the look and feel of the web pages from a master page. I tried to inherit Xhtml class in one of the pages. I am using RadTab and RadMultiviewPage control in this page. Please note the code. I am getting a NullReferenceException in the Xhtml.cs. Is there a version of Xhtml.cs suitable for web pages generated from Master control. I noted that the demo site also does not use Master page.

    Line 56:         Control form = FindForm();
    Line 57:
    Line 58:         return Regex.Replace(input, @"theform\s+=\s+document\..*?;",
    Line 59:             string.Format("theform = document.getElementById(\"{0}\");",
    Line 60:             form.ClientID)

    public

    partial class Enroll_Enroll : XhtmlPage

    {

    protected void Page_Load(object sender, EventArgs e)

    {

    if (!Page.IsPostBack)

    {

    AddTab(

    "Client Type", true);

    RadPageView pageView = new RadPageView();

    pageView.ID =

    "ClientType";

    RadMultiPage1.PageViews.Add(pageView);

    AddTab(

    "Parents Info", false);

    AddTab(

    "Home Address", false);

    }

    }

    private void AddTab(string tabName, bool enabled)

    {

    RadTab tab = new RadTab(tabName);

    tab.Enabled = enabled;

    RadTabStrip1.Tabs.Add(tab);

    }

    protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)

    {

    //Control pageViewContents = LoadControl(@"~\WebControls\ClientType.ascx");

    //pageViewContents.ID = e.PageView.ID + "userControl";

    //e.PageView.Controls.Add(pageViewContents);

    string controlid = @"..\WebControls\" + e.PageView.ID + ".ascx";

    Control pageViewContents = LoadControl(controlid);

    pageViewContents.ID = e.PageView.ID +

    "userControl";

    e.PageView.Controls.Add(pageViewContents);

    }

    }

        

  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 08 May 2008 Link to this post

    Hello Binu,

    The Xhtml page is not required for using RadControls. It is used in our demos just to provide Xhtml 1.1 compliance.

    Regards,
    Albert
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Binu
    Binu avatar
    2 posts
    Member since:
    Apr 2008

    Posted 08 May 2008 Link to this post

    Hi Albert,

    Thanks for your prompt response. The reason I tried to use Xhtml.cs was to supress the "Multiple controls with same Id 'ParentInfo' were found. FindControl requires that controls have unique IDs" error. I get this error when I populate Tab1, click the "Continue" button and go to Tab 2, populate the controls on Page2 and then click the Tab1 again. Now when I click the "Continue button, FindControl method throws "Multiple controls with same Id 'ParentInfo' were found. FindControl requires that controls have unique IDs" error. This does not happen in case of Wizard demo.

    The only difference between my code and the Wizard demo code is use of Master page in my case and the use of Xhtml.cs in case of Wizard Demo.

    I would appreciate any help to resolve this issue.


    Regards,
    Binu
  4. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 09 May 2008 Link to this post

    Hello Binu,

    Please check that you are not adding the same control twice in your application. Keep in mind the PageViewCreated event is now fired always (not only after postback).

    I hope this helps,
    Albert
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top