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

NullReferenceException in the Xhtml.cs

3 Answers 65 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Binu
Top achievements
Rank 1
Binu asked on 07 May 2008, 10:26 PM

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);

}

}

    

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 08 May 2008, 08:13 AM
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
0
Binu
Top achievements
Rank 1
answered on 08 May 2008, 02:26 PM
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
0
Atanas Korchev
Telerik team
answered on 09 May 2008, 07:05 AM
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
Tags
TabStrip
Asked by
Binu
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Binu
Top achievements
Rank 1
Share this question
or