Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I want to create Web control in runtime..

Is it possible ?

If so how?

 

the following code is the one I wrote, but failed

 

/ Put user code to initialize the page here

lbs= new Label[5];

lbs[0] = new Label();

lbs[0].Text = "label 0 ";

//style="Z-INDEX: 101; LEFT: 103px; POSITION: absolute; TOP: 98px"

//lbs[0].Style = "Z-INDEX: 101; LEFT: 103px; POSITION: absolute; TOP: 120px";

//lbs[0].ControlStyle;

lbs[0].Visible=true;

 

lbs[1] = new Label();

lbs[1].Text = "label 1 ";

 

//lbs[1].Style = "Z-INDEX: 101; LEFT: 103px; POSITION: absolute; TOP: 140px"; //Style if read only property.. so , it doesn't work..

lbs[1].Visible=true;

 

with this code, lbs doesn't show up...-.-

Sun Certified Web component Developer,

Microsoft Certified Solution Developer .NET,

Software Engineer

  • Moderators
Posted
       Dim x As Integer

       For x = 0 To 10
           Dim lbl As New Label()

           With lbl
               .BorderColor = Color.Red
               .BorderStyle = BorderStyle.Solid
               .BorderWidth = Unit.Pixel(1)
               .Text = "Test"
               .CssClass = "SomeCssClass" 'If you wish, use this instead of the properties
           End With
           Me.Controls.Add(lbl) 'or place the controls into a Panel or PlaceHolder

       Next

Visit...Bassic Software
  • Moderators
Posted

Sorry I just noticed you'r using C#

		{
		 
			for (int i = 1; i <= 10; i++) 
			{
				Label lbl;
				lbl = new Label();
				lbl.BorderColor = Color.Red;
				lbl.BorderStyle = BorderStyle.Solid;
				lbl.BorderWidth = Unit.Pixel(1);
				lbl.Text = "Test";
				lbl.CssClass = "SomeCssClass"; //If you wish, use this instead of the properties
				this.Controls.Add(lbl); //or place the controls into a Panel or PlaceHolder

			}

		

Visit...Bassic Software
Posted

Thank you for your help.

Could you explain more about cssClass and give me example?

Specially about setting X, Y, Z location on the screen..

 

And additionally how can I write click event handler of the generated label arrary?

Sun Certified Web component Developer,

Microsoft Certified Solution Developer .NET,

Software Engineer

  • 2 months later...
Posted

Using the VB code provided by Robby, I can create all the labels I need at runtime but they have a mind of their own. First they just line up one after another along the left margin and when you view the source, all of the code created at runtime code is listed after the </html> tag.

 

How can I control where they go? Does it have something to do with BindingContainer or NamingContainter?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...