| Author: Abhinav Dawra 05 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
in an asp.net page you can create controls dynamically by instantiating the object of the control class and then adding that control on the page. e.g. To create a dynamic label use Label l = new Label(); Page.Controls.Add(l);
This will add the control to this page.
Thanks, Abhinav Please rate if this answer was helpful
|
| Author: Devendra 05 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
There is 2 way to add control dynamically
One add HTML controls using string builder another on user control class object.
Ist Option StringBuilder sb = new StringBuilder(); sb.append("<input type='text' size='20' value='' ID='text1' />");
2nd Option TextBox txt1 = new textBox(); PlaceHolder.Controls.Add(txt1);
By this way you can add dynamic controls on your page.
Thakns dkmisra
|
| Author: Deepika Haridas 05 Jul 2009 | Member Level: Diamond | Rating:  Points: 2 |
Hi,
Here is a sample code
Dim lblMessage as New Label() lblMessage.Text = "Hello, World!" lblMessage.Font.Bold = True
'Finally, we need to add this control to the Web page. Not surprisingly, the Controls property has an Add method, which is demonstrated in the following code:
Controls.Add(lblMessage)
Thanks & Regards, Deepika Editor
If U want to shine like a SUN..First U have to burn like the SUN!! Need a Guide? Join my mentor program..
|
| Author: UltimateRengan 05 Jul 2009 | Member Level: Diamond | Rating:  Points: 2 |
Partial Class _Default Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim btn As Button Dim txt As TextBox For i As Integer = 0 To 2 btn = New Button txt = New TextBox txt.ID = "Textbox" & i txt.Text = "Textbox" & i btn.Text = "DynamicButton" & i btn.ID = "DynamicButton" & i AddHandler txt.TextChanged, AddressOf Txt_TextChanged AddHandler btn.Click, AddressOf btn_Click form1.Controls.Add(btn) form1.Controls.Add(txt) Next End Sub Protected Sub btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Response.Write("G.Renganathan(UltimateRengan" & CType(sender, Button).ID) End Sub
Protected Sub Txt_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Response.Write("Hai") End Sub End Class
Advance Happy Diwali SAP B1
|
| Author: pradeep 06 Jul 2009 | Member Level: Silver | Rating: Points: 1 |
with objects
|