Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2005

Tip: Looking for answers? Try searching our database.

Controls.Add clash with Inner.Html?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Frank_00001 - 14 Jul 2005 20:57 GMT
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?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.