Click here to Skip to main content
16,019,263 members
Home / Discussions / C#
   

C#

 
GeneralRe: Finding the * Pin
Daniel Turini10-Oct-02 6:01
Daniel Turini10-Oct-02 6:01 
GeneralRe: Finding the * Pin
Nnamdi Onyeyiri10-Oct-02 6:01
Nnamdi Onyeyiri10-Oct-02 6:01 
GeneralRe: Finding the * Pin
David Stone10-Oct-02 14:03
sitebuilderDavid Stone10-Oct-02 14:03 
GeneralRe: Finding the * Pin
Eric Gunnerson (msft)11-Oct-02 10:52
Eric Gunnerson (msft)11-Oct-02 10:52 
GeneralRe: Finding the * Pin
David Stone11-Oct-02 13:48
sitebuilderDavid Stone11-Oct-02 13:48 
GeneralEmail header Pin
Tomas Petricek9-Oct-02 12:11
Tomas Petricek9-Oct-02 12:11 
GeneralRe: Email header Pin
leppie9-Oct-02 12:50
leppie9-Oct-02 12:50 
QuestionAbstract Class instance? Pin
ximian9-Oct-02 10:47
ximian9-Oct-02 10:47 
Problem with -> ASP.NET using C#

I am creating a custom user control that reads an xml file and dynamically places labels on the control. This user control will then be placed inside a webform

I am suddenly stuck because I know if I wanted to add dynamically generated controls without a custom user control, which I probably may end up doing if this does not work, I could easily just add this under OnInit function (which is generated by the forms designer.

override protected void OnInit(EventArgs e)
{
// Create dynamic controls here.
// Use "using System.Web.UI.WebControls;"
TextBox1 = new TextBox();
TextBox1.ID = "TextBox1";
TextBox1.Style["Position"] = "Absolute";
TextBox1.Style["Top"] = "25px";
TextBox1.Style["Left"] = "100px";
Form1.Controls.Add(TextBox1);
}

yeah thats from this Q Article.

Thats all fine and good, but you see this line:

Form1.Controls.Add(TextBox1);

What would be the equivalent in a custom User control.

Say my Control is called MyControl.ascx

in my function that reads the xml file and attempts to programatically create a label, every thing is just peachy..but how do I place the label inside my custom control?

I cannot do this:
MyControl somecontrol = new MyControl();
and then in the function do

somecontrol.Contols.Add(myLabel)


wont work!

Cannot create instance of Abstract class or interface? Bah! Dead | X|

I guess I will do it directly from the WebForm, but I just thought there was tremendous coolness value to get it working through a custom control that I could add to a webform without cluttering the webform with all this.

Oh well...if anyone has comments about creating an instance of an abstract class please post!
AnswerRe: Abstract Class instance? Pin
Paul Riley9-Oct-02 11:52
Paul Riley9-Oct-02 11:52 
GeneralRe: Abstract Class instance? Pin
ximian9-Oct-02 14:37
ximian9-Oct-02 14:37 
GeneralRe: Abstract Class instance? Pin
ximian10-Oct-02 2:59
ximian10-Oct-02 2:59 
GeneralRe: Abstract Class instance? Pin
Paul Riley10-Oct-02 4:05
Paul Riley10-Oct-02 4:05 
Generaldetecting right click on tabcontrol tab Pin
Darryl Borden9-Oct-02 8:52
Darryl Borden9-Oct-02 8:52 
GeneralHandling of unmanaged code by the .NET environment Pin
abhinarulkar9-Oct-02 6:12
abhinarulkar9-Oct-02 6:12 
GeneralRe: Handling of unmanaged code by the .NET environment Pin
Eric Gunnerson (msft)9-Oct-02 8:31
Eric Gunnerson (msft)9-Oct-02 8:31 
GeneralOrder of events when a form is displayed Pin
Wjousts9-Oct-02 2:00
Wjousts9-Oct-02 2:00 
GeneralRe: Order of events when a form is displayed Pin
Daniel Turini9-Oct-02 4:01
Daniel Turini9-Oct-02 4:01 
GeneralRe: Order of events when a form is displayed Pin
Gaul9-Oct-02 5:24
Gaul9-Oct-02 5:24 
GeneralRe: Order of events when a form is displayed Pin
Wjousts9-Oct-02 10:54
Wjousts9-Oct-02 10:54 
Questionhow to do it??? Pin
8-Oct-02 21:04
suss8-Oct-02 21:04 
AnswerRe: how to do it??? Pin
Marc Clifton9-Oct-02 0:10
mvaMarc Clifton9-Oct-02 0:10 
QuestionPlatform invoke??? Pin
Vu Truong8-Oct-02 17:54
Vu Truong8-Oct-02 17:54 
AnswerRe: Platform invoke??? Pin
Stephane Rodriguez.8-Oct-02 19:31
Stephane Rodriguez.8-Oct-02 19:31 
GeneralRe: Platform invoke??? Pin
Vu Truong8-Oct-02 21:08
Vu Truong8-Oct-02 21:08 
AnswerRe: Platform invoke??? Pin
Richard Deeming9-Oct-02 1:22
mveRichard Deeming9-Oct-02 1:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.