goodmorningsky Posted October 14, 2003 Posted October 14, 2003 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...-.- Quote Sun Certified Web component Developer, Microsoft Certified Solution Developer .NET, Software Engineer
Moderators Robby Posted October 14, 2003 Moderators Posted October 14, 2003 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 Quote Visit...Bassic Software
Moderators Robby Posted October 14, 2003 Moderators Posted October 14, 2003 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 } Quote Visit...Bassic Software
goodmorningsky Posted October 15, 2003 Author Posted October 15, 2003 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? Quote Sun Certified Web component Developer, Microsoft Certified Solution Developer .NET, Software Engineer
Moderators Robby Posted October 15, 2003 Moderators Posted October 15, 2003 Css is the style sheets you can set, find out more here http://www.w3schools.com/css What knid of events do you want ot handle for labels? Quote Visit...Bassic Software
goodmorningsky Posted October 15, 2003 Author Posted October 15, 2003 I need to handle click event to all the label elements of the Label array Quote Sun Certified Web component Developer, Microsoft Certified Solution Developer .NET, Software Engineer
LawS Posted December 17, 2003 Posted December 17, 2003 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? Quote
Moderators Robby Posted December 17, 2003 Moderators Posted December 17, 2003 Instead of adding them to the page you can add them to a panel or even <table><td> tags. Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.