creation of controls dynamically and handling the controls

M

Murthy

Hi,

I would like to develop an application such that it

should create a combobox(server side control) at runtime

and how should handle these controls at runtime.
In my case i have a link button "add the

control".whenever i click on the button it should create

the combobox serverside control and i am using the code

behing file mechanisam.

Plz can any one help me.


Regards,
Krishna.
 
C

Cor Ligthert

Murthy,

This should be in the newsgroups, however I see that all those samples are
disapeared in Google. (It creates a kind of calandar with buttons)

Here it is again an old sample of my.

\\\Needs a panel on the page where the name panel is deleted
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim mybutton As Button
Dim i As Integer
For i = 0 To New Date().DaysInMonth _
(New Date().Year, New Date().Month) - 1
mybutton = New Button
mybutton.BackColor = Drawing.Color.White
mybutton.Text = (i + 1).ToString
mybutton.Width = New Unit(30)
Me.Panel1.Controls.Add(mybutton)
AddHandler mybutton.Click, AddressOf mybutton_Click
If (i + 1) Mod 5 = 0 Then
Me.Panel1.Controls.Add(New LiteralControl("<BR>"))
End If
Next
End Sub
Private Sub mybutton_Click _
(ByVal sender As Object, ByVal e As System.EventArgs)
Dim mylabel As New Label
Me.Panel1.Controls.Add(New LiteralControl("<BR><BR>"))
Me.Panel1.Controls.Add(mylabel)
mylabel.Text = "The day is: " & DirectCast(sender, Button).Text
End Sub
////

I hope this helps,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top