How to position web server contols at run time?

  • Thread starter Thread starter andrew
  • Start date Start date
A

andrew

Quite possibly a simple one.
I wish to build a web page which will encompass multi
functionality (i.e. it wil accept relevant entries to
perform a variety of procedure against my data base).
When I call the form I pass a query string and use select
statements to determine what the form is supposed to be
doing. I then want to dynamically position server
controls onto the rendered page in response to this. My
problem: I can't seem to see any property which will
allow me to set a location for each control which I can
specify at run time. In windows forms I would use the
location property and then the size.
With the web forms I can see how the height and width can
be dynamically controlled, but not the start point. Also
in the underlying html I can see how the starting location
may be set, but am unsure of how to incorporate this from
my VB environment.

Thanking anyone in advance.

Andrew
 
Hi Andrew,

I did not make this sample for this, but you can look what it can do for
you.

One of the most important things, you have to add a panel yourself on the
form.

\\\
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim mybutton(31) As Button
Dim i As Integer
For i = 0 To New Date().DaysInMonth _
(New Date().Year, New Date().Month) - 1
mybutton(i) = New Button
mybutton(i).BackColor = Drawing.Color.White
mybutton(i).Text = (i + 1).ToString
mybutton(i).Width = New Unit(30)
Me.Panel1.Controls.Add(mybutton(i))
AddHandler mybutton(i).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

Link
http://msdn.microsoft.com/library/d...l/vbtskcodeexampleaddingcontrolsatruntime.asp

I hope this helps a little bit?

Cor
 
Back
Top