I'm trying to dynamically create controls on a <DIV>; however I want to add
an <HR> in between certain controls, seems simple enough. I'm having trouble
with the <HR>, I was going to just add it using InnerHtml.Insert; but for
some reason after adding a control, the InnerHtml seems to get corupted,
<error: an exception of type: {System.Web.HttpException} occurred>.
Here's basically what I want to do, content is the <DIV> and the control I'm
adding is a user control.
Control empNominator = null;
empNominator = LoadControl("EmployeeRecordReadOnly.ascx");
if (empNominator != null)
{
((EmployeeRecordReadOnly)empNominator).EmployeeType = "NR";
((EmployeeRecordReadOnly)empNominator).UpdateEmployeeControlsFromData(DataSet1);
content.Controls.Add(((EmployeeRecordReadOnly)empNominator));
content.InnerHtml.Insert(content.InnerHtml.Length, "<HR style=\"HEIGHT:
1px\" width=\"100%\" SIZE=\"1\">");
}
Any ideas?
societopia.net - 14 Jul 2005 21:35 GMT
The InnerHtml property brings the literal content of the GenericControl but
in your code below "content" had only a control "empNominator" that had not
been rendered to HTML yet. Try creating a generic control for the <HR>
markup then add it to your content control:
HtmlGenericControl HRDiv = new HtmlGenericControl ();
HRDiv.InnerHtml ="<HR style=\"HEIGHT: 1px\" width=\"100%\" SIZE=\"1\">";
content.Controls.Add(((EmployeeRecordReadOnly)empNominator));
content.Controls.Add(HRDiv);
---
www.societopia.net
> I'm trying to dynamically create controls on a <DIV>; however I want to add
> an <HR> in between certain controls, seems simple enough. I'm having trouble
[quoted text clipped - 18 lines]
>
> Any ideas?