473,406 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Controls.Add clash with Inner.Html?

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).EmployeeTyp e = "NR";

((EmployeeRecordReadOnly)empNominator).UpdateEmplo yeeControlsFromData(DataSet1);
content.Controls.Add(((EmployeeRecordReadOnly)empN ominator));
content.InnerHtml.Insert(content.InnerHtml.Length, "<HR style=\"HEIGHT:
1px\" width=\"100%\" SIZE=\"1\">");
}

Any ideas?
Nov 19 '05 #1
1 2137
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)empN ominator));
content.Controls.Add(HRDiv);

---
www.societopia.net
"Frank_00001" wrote:
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).EmployeeTyp e = "NR";

((EmployeeRecordReadOnly)empNominator).UpdateEmplo yeeControlsFromData(DataSet1);
content.Controls.Add(((EmployeeRecordReadOnly)empN ominator));
content.InnerHtml.Insert(content.InnerHtml.Length, "<HR style=\"HEIGHT:
1px\" width=\"100%\" SIZE=\"1\">");
}

Any ideas?

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Guadala Harry | last post by:
I have this scenario: ASPX Page dynamically loads userControl1 - which in turn dynamically loads userControl2. UserControl2 contains a TextBox Web Server control. When a user clicks a button in...
5
by: Neal | last post by:
Hi I need to change my mousepointer when the mouse moves over certain populated controls on my aspx page. I've tried the following but without success (after visiting a site recommended from...
1
by: E. Tom Jorgenson | last post by:
I've run into a problem on a couple of projects that I think I've identified - but would like confirmation of what I think is going on. Also interested in any fast solutions to fix the user...
4
by: Michael | last post by:
Hi everyone, I just used the upgrade wizard to upgrade a project of mine. One of the main forms I have has over 200 controls on the form, Uses some tab controls. Now, I have a main tab control...
2
by: Deepa K | last post by:
Hi, In my PC, eth0 is not up because of IP address clash (another PC is using the same IP address). I tried to execute a file which has set of insert commands. After executing the file, when I go...
11
by: Nick Gilbert | last post by:
Hi, How can I create a custom control which will wrap its content in a header and footer? eg: Is it possible to create a .NET user control which can surround other controls? eg:...
16
by: =?iso-8859-2?Q?K=F8i=B9tof_=AEelechovski?= | last post by:
I need a form control for the user to enter currency symbol. A select control seems to be fit for that purpose; but the problem is that the control must appear on the page several times so the...
5
by: Nathan Sokalski | last post by:
I am writing a Control that inherits from System.Web.UI.WebControls.CompositeControl. Like many Controls, my Control renders more than just one inner Control. When a postback occurs, I need to get...
5
by: gerry | last post by:
I am trying to create a custom container control that will only ever contain a specific type of control. At design time, when a control of a different type is added to the container I would like...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.