CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > visual_studio.visual_studio_2005 Tags:
Item Type: NewsGroup Date Entered: 9/6/2006 3:14:28 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 2 Views: 14 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
3 Items, 1 Pages 1 |< << Go >> >|
Zorthgo
Asp.Net User
Creaeting dynamically a webcontrol9/6/2006 3:14:28 PM

0/0

Hi guys, I'm Stuck on a project that I'm working on, I need to creat controls dinamically on my web page. Although my label is working fine, when I try to create a checkbox I keep geting an error message "Control 'Checkbox1' of type 'CheckBox' must be placed inside a form tag with runat=server." Can anyone help me with this?

<---------------------------------------- CODE ---------------------------------------->

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim I As Integer

        For I = 1 To 5
            Dim L As New Label
            L.ID = "Lable" & I
            L.Text = "<b>Whatz Up</b><br><table border=0  align=JUSTIFY  valign=Top width=95%><tr><td ALIGN=LEFT ><font size=1  color=""#333333"" face=Arial>Testing</font></td></tr></table>"
            Me.Controls.Add(L)
            ListBox1.Items.Add(L.ID)
        Next

        For I = 1 To 5
            Dim t As CheckBox = New CheckBox

            t.ID = "Checkbox" & I
            t.Attributes.Add("runat", "Server")
            t.Font.Name = "Arial"
            t.Font.Size = FontUnit.Point(10)
            t.Text = "<b> Sup</font></td></tr></table>"
            t.Enabled = True
            t.Visible = True
            t.Checked = True




            Me.Controls.Add(t)
            ListBox2.Items.Add(t.ID)


        Next


    End Sub

 <---------------------------------------------------------------------------------------->

 

Thanks for the Help!Big Smile

vivek_iit
Asp.Net User
Re: Creaeting dynamically a webcontrol9/6/2006 8:28:50 PM

0/0

Hi,

Create a PlaceHolder control on your web form and add dynamic controls in it as:

Me.Placeholder1.Controls.Add(l) 

Tthis will add the server control inside the PlaceHolder which is already inside the form tag as most webcontrols with runat=server need to be present under a form tag

Hope this helps,

Vivek


MVP, ASP.NET || My Website || Blog || Articles

Please mark the most helpful reply/replies as "Answer".
Zorthgo
Asp.Net User
Re: Creaeting dynamically a webcontrol9/6/2006 8:31:21 PM

0/0

thanks vivek_ii it worked!!!  Big Smile
3 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Pro ASP.NET 2.0 in C# 2005 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1255, Published: 2005
.NET Programming 10-minute Solutions: 10-Minute Solutions Authors: A. Russell Jones, Mike Gunderloy, Pages: 433, Published: 2004
ASP.NET in a Nutshell: In a Nutshell Authors: G. Andrew Duthie, Matthew MacDonald, Pages: 979, Published: 2003
Pro ASP.NET 2.0 in C# 2005: Create Next-generation Web Applications with the Latest Version of Microsoft's Revolutionary Technology Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1426, Published: 2006
Professional C# 2005 Authors: Christian Nagel, Bill Evjen, Jay Glynn, Karli Watson, Morgan Skinner, Allen Jones, Pages: 1540, Published: 2006
Professional C# Authors: Simon Robinson, Christian Nagel, Karli Watson, Jay Glynn, Morgan Skinner, Bill Evjen, Pages: 1224, Published: 2004
Professional C# 2005 with .NET 3.0 Authors: Christian Nagel, Bill Evjen, Jay Glynn, Karli Watson, Morgan Skinner, Pages: 1748, Published: 2007
Professional C# 2008 Authors: Christian Nagel, Bill Evjen, Jay Glynn, Karli Watson, Morgan Skinner, Pages: 1782, Published: 2008
ASP.NET 1.1 Solutions Toolkit Authors: Victor Garcia Aprea, Daniel Cazzulino, Richard Delorme, Robin Dewson, Fabio Claudio Ferracchiati, David Gottlieb, Matthew MacDonald, Saurabh Nandu, Pages: 318, Published: 2004

Web:
Creaeting dynamically a webcontrol - ASP.NET Forums Re: Creaeting dynamically a webcontrol. 09-06-2006, 4:28 PM. Contact. Answer ... Re: Creaeting dynamically a webcontrol. 09-06-2006, 4:31 PM. Contact ...
Label Class (System.Web.UI.WebControls) How to: Create Templates Dynamically in DataList Web Server Controls, Building ASP . ... Walkthrough: Creating and Using ASP.NET Master Pages in Visual Web ...
Atanas Korchev's blog > On dynamically creating server controls On dynamically creating server controls. Thursday, September 27, 2007 ... public class MyControl : WebControl, INamingContainer ...
Wiring Up Event Handlers to Dynamically Created Custom Server Controls Click event. In the MyButton.Click event handler I am dynamically creating a System.Web.UI.WebControl.Label to display some information. ...
WebControl.Style and ViewState microsoft.public.dotnet.framework.aspnet.webcontrols. Author. 19 Jul 2005 2:41 PM. Mesalem. i'm creating a text box dynamically in the page ...
Handling events on automatically generated web controls I am dynamically creating WebControls and creating them on my page. Some of these are buttons, and I attach events to these buttons. ...
ASP.NET Custom Server Controls: Dynamically Expandable Round ... Oct 10, 2005 ... This article introduces you to creating your own dynamically expandable ... WebControls.WebControl as the base class, just because of the ...
Populating Controls - Form Load Dynamically - .NET ASP NET, dynamically creating webcontrols is naturally supported. Here are some web articles introducing this: #HOW TO: Dynamically Create ...
XML Parsing for dynamically creating controls - ASP.NET Forums But "Linq to xml" is not used for creating dynamically controls. ... WebControl target = (System.Web.UI.WebControls.WebControl)obj; target. ...
Label Class (System.Web.UI.WebControls) How to: Create Templates Dynamically in DataList Web Server Controls ... Walkthrough: Creating a Basic Control Designer for a Web Server Control ...




Search This Site:










create custom control?

ttt gallery flash problem dnn3.0.13

please help me about change vs 2005 layout

partially trusted callers

a little disappointed

how to get applicationid?

dynamic controls

how an accout was locked even input corrected?

form authentication bypassed when users requesting word/excel files directly

import & export

sorry , is there anyone can teach me how to get comonent's id???

default settings - login page/tab 3.0.7

collectioneditor for extended panels

mixed authentication

initializing personalization values from db

master page containing a tree view control and mapping is done in web.sitemap

copying aspx/aspx.vb pages

freetextbox could not be loaded (3.0.7)

long running queries times out..

so... how best to setup dnn?

child to parent

migrating site and db to new server

the membership provider name specified is invalid.

html formatting code from excel in html document module

control not setting auth ticket

select certificate dialog

roles and sql server access

where do i begin to make a skin object?

alternative .net based e-commerce packages

problems moving portal from one server to another

 
All Times Are GMT