|
-
Feb 4th, 2004, 06:05 AM
#1
Thread Starter
New Member
A bit stuck adding code to Buttons
I'm writing a program which accessess function in a .dll which occasionally raises events. I'm Caputuring these events within my program and I want to display a prompt (much like a modal dialog box) so the user can ok/cancel it. I've donr the code which creates the Box , labels and buttons but what I can't seem to work out is how to attach code to the buttons I have created. Bascially all I want is when they click a button it sets a values to true or false. Because the button doesn't exist until runtime I cant add an event handler, is there a way to do this when I create the button?
This function is in a code file and creates the button:
Code:
Dim wcButton As New Button
wcButton.ID = Name
wcButton.Text = defaultvalue
wcButton.Style.Add("Position", "Relative")
wcButton.Style.Add("Left", Left)
wcButton.Style.Add("Top", Top)
wcButton.Style.Add("Height", Height)
wcButton.Style.Add("Width", Width)
wcButton.Enabled = Enabled
wcButton.Visible = Visible
wcButton.ToolTip = Tooltip
If (TabIndex <> 0) Then
wcButton.TabIndex = TabIndex
End If
The event handler calls a function to create a Prompt which creates a GenericHTMLControl and add the buttons and Labels as WebControls. This generic Control is then added to the page.
I'm not entirly sure if this is the correct approach for how to create Modal style dialogs so if anyone else has a good way to implement them in ASP.NET please tell me.
Andrew Aitken
-
Feb 4th, 2004, 02:45 PM
#2
Hyperactive Member
Hi, add an event handler to the button (Something like this)
VB Code:
Dim wcButton As New Button
wcButton.ID = Name
wcButton.Text = defaultvalue
wcButton.Style.Add("Position", "Relative")
wcButton.Style.Add("Left", Left)
wcButton.Style.Add("Top", Top)
wcButton.Style.Add("Height", Height)
wcButton.Style.Add("Width", Width)
wcButton.Enabled = Enabled
wcButton.Visible = Visible
wcButton.ToolTip = Tooltip
AddHandler wcButton.Click, AddressOf My_Clicker
' Add in a Javascript Yes/ No button
wcButton.Attributes.Add("onclick", "return confirm('Are you sure you want to do something?');")
' then click function
Private Sub My_Clicker(sender As Object, e As EventArgs)
Response.Write(Sender.ID & " Has been clicked")
End Sub
Cheers
MarkusJ
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|