472,794 Members | 2,235 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,794 software developers and data experts.

button click event

Hi, All,

I create button in the code ( Dim Button as new Button), not using button
web component (means not drap button and drop it ont he webform), after that
I try to use button_click event, it is not work, anyone can tell how to use
button click event ?

Thanks in advance,
Martin
May 24 '07 #1
7 6773
On May 24, 12:53 pm, martin1 <mart...@discussions.microsoft.com>
wrote:
Hi, All,

I create button in the code ( Dim Button as new Button), not using button
web component (means not drap button and drop it ont he webform), after that
I try to use button_click event, it is not work, anyone can tell how to use
button click event ?

Thanks in advance,
Martin
AddHandler

Thanks,

Seth Rowe

May 24 '07 #2
Hi, Seth Rowe,

could you give sample on how to use addhandler,

Thanks,
martin

"rowe_newsgroups" wrote:
On May 24, 12:53 pm, martin1 <mart...@discussions.microsoft.com>
wrote:
Hi, All,

I create button in the code ( Dim Button as new Button), not using button
web component (means not drap button and drop it ont he webform), after that
I try to use button_click event, it is not work, anyone can tell how to use
button click event ?

Thanks in advance,
Martin

AddHandler

Thanks,

Seth Rowe

May 24 '07 #3
On May 24, 1:36 pm, martin1 <mart...@discussions.microsoft.comwrote:
Hi, Seth Rowe,

could you give sample on how to use addhandler,

Thanks,
martin

"rowe_newsgroups" wrote:
On May 24, 12:53 pm, martin1 <mart...@discussions.microsoft.com>
wrote:
Hi, All,
I create button in the code ( Dim Button as new Button), not using button
web component (means not drap button and drop it ont he webform), after that
I try to use button_click event, it is not work, anyone can tell how to use
button click event ?
Thanks in advance,
Martin
AddHandler
Thanks,
Seth Rowe
Private Sub Form_Load(sender As Object, e As EventArgs)
Dim btn as new Button()
AddHandler btn.Click, AddressOf Button_Click
End Sub

Private Sub Button_Click(sender As Object, e As EventArgs)
' Do something useful
End Sub

Thanks,

Seth Rowe

May 24 '07 #4
Thank you! Seth Rowe

What I want to do is let user click each button to pop up message which is
related to StatusDesc field of Sysstat Table, the message is dynamic. The
problem (look at code below) is StatusDesc message is overwritten by next
loop, so how to keep statusDesc message for each button?

The Code like:
---------------------------------------------------
Pub Class _Default
Dim StatusDesc As String

Private Sub Form_Load(sender As Object, e As EventArgs)

For Each row In dtSysstat.Rows ' loop each record of sysstat table
Dim button As New Button ' create button for each row

btnText = Trim(row.Item("ButtonName")) ' get ButtonName
from table
StatusDesc = Trim(row.Item("StatusDesc").ToString) 'get
StatusDesc

button.Text = btnText
panel.Controls.Add(button)

' add click event to button
AddHandler button.Click, AddressOf Button_click
End Sub

Private Sub Button_Click(sender As Object, e As EventArgs)
MsgBox(StatusDesc)
End Sub

End Class
------------------------------------------------
Thank you again,
Martin
"rowe_newsgroups" wrote:
On May 24, 1:36 pm, martin1 <mart...@discussions.microsoft.comwrote:
Hi, Seth Rowe,

could you give sample on how to use addhandler,

Thanks,
martin

"rowe_newsgroups" wrote:
On May 24, 12:53 pm, martin1 <mart...@discussions.microsoft.com>
wrote:
Hi, All,
I create button in the code ( Dim Button as new Button), not using button
web component (means not drap button and drop it ont he webform), after that
I try to use button_click event, it is not work, anyone can tell how to use
button click event ?
Thanks in advance,
Martin
AddHandler
Thanks,
Seth Rowe

Private Sub Form_Load(sender As Object, e As EventArgs)
Dim btn as new Button()
AddHandler btn.Click, AddressOf Button_Click
End Sub

Private Sub Button_Click(sender As Object, e As EventArgs)
' Do something useful
End Sub

Thanks,

Seth Rowe

May 24 '07 #5

"martin1" <ma*****@discussions.microsoft.comwrote in message
news:09**********************************@microsof t.com...
Thank you! Seth Rowe

What I want to do is let user click each button to pop up message which is
related to StatusDesc field of Sysstat Table, the message is dynamic. The
problem (look at code below) is StatusDesc message is overwritten by next
loop, so how to keep statusDesc message for each button?

The Code like:
---------------------------------------------------
Pub Class _Default
Dim StatusDesc As String

Private Sub Form_Load(sender As Object, e As EventArgs)

For Each row In dtSysstat.Rows ' loop each record of sysstat table
Dim button As New Button ' create button for each row

btnText = Trim(row.Item("ButtonName")) ' get ButtonName
from table
StatusDesc = Trim(row.Item("StatusDesc").ToString) 'get
StatusDesc

button.Text = btnText
panel.Controls.Add(button)

' add click event to button
AddHandler button.Click, AddressOf Button_click
End Sub

Private Sub Button_Click(sender As Object, e As EventArgs)
MsgBox(StatusDesc)
End Sub

End Class
------------------------------------------------
Thank you again,
Martin
"rowe_newsgroups" wrote:
>On May 24, 1:36 pm, martin1 <mart...@discussions.microsoft.comwrote:
Hi, Seth Rowe,

could you give sample on how to use addhandler,

Thanks,
martin

"rowe_newsgroups" wrote:
On May 24, 12:53 pm, martin1 <mart...@discussions.microsoft.com>
wrote:
Hi, All,

I create button in the code ( Dim Button as new Button), not using
button
web component (means not drap button and drop it ont he webform),
after that
I try to use button_click event, it is not work, anyone can tell
how to use
button click event ?

Thanks in advance,
Martin

AddHandler

Thanks,

Seth Rowe

Private Sub Form_Load(sender As Object, e As EventArgs)
Dim btn as new Button()
AddHandler btn.Click, AddressOf Button_Click
End Sub

Private Sub Button_Click(sender As Object, e As EventArgs)
' Do something useful
End Sub

Thanks,

Seth Rowe

When you create the button, set btn.tag = StatusDesc. Then when you handle
the click event you can cast the sender to a button and retrieve the tag as
the description.

Hope this helps

Lloyd Sheen

May 24 '07 #6
Hi, Lloyd Sheen,

it works, Thank you so much,

Martin

"Lloyd Sheen" wrote:
>
"martin1" <ma*****@discussions.microsoft.comwrote in message
news:09**********************************@microsof t.com...
Thank you! Seth Rowe

What I want to do is let user click each button to pop up message which is
related to StatusDesc field of Sysstat Table, the message is dynamic. The
problem (look at code below) is StatusDesc message is overwritten by next
loop, so how to keep statusDesc message for each button?

The Code like:
---------------------------------------------------
Pub Class _Default
Dim StatusDesc As String

Private Sub Form_Load(sender As Object, e As EventArgs)

For Each row In dtSysstat.Rows ' loop each record of sysstat table
Dim button As New Button ' create button for each row

btnText = Trim(row.Item("ButtonName")) ' get ButtonName
from table
StatusDesc = Trim(row.Item("StatusDesc").ToString) 'get
StatusDesc

button.Text = btnText
panel.Controls.Add(button)

' add click event to button
AddHandler button.Click, AddressOf Button_click
End Sub

Private Sub Button_Click(sender As Object, e As EventArgs)
MsgBox(StatusDesc)
End Sub

End Class
------------------------------------------------
Thank you again,
Martin
"rowe_newsgroups" wrote:
On May 24, 1:36 pm, martin1 <mart...@discussions.microsoft.comwrote:
Hi, Seth Rowe,

could you give sample on how to use addhandler,

Thanks,
martin

"rowe_newsgroups" wrote:
On May 24, 12:53 pm, martin1 <mart...@discussions.microsoft.com>
wrote:
Hi, All,

I create button in the code ( Dim Button as new Button), not using
button
web component (means not drap button and drop it ont he webform),
after that
I try to use button_click event, it is not work, anyone can tell
how to use
button click event ?

Thanks in advance,
Martin

AddHandler

Thanks,

Seth Rowe

Private Sub Form_Load(sender As Object, e As EventArgs)
Dim btn as new Button()
AddHandler btn.Click, AddressOf Button_Click
End Sub

Private Sub Button_Click(sender As Object, e As EventArgs)
' Do something useful
End Sub

Thanks,

Seth Rowe


When you create the button, set btn.tag = StatusDesc. Then when you handle
the click event you can cast the sender to a button and retrieve the tag as
the description.

Hope this helps

Lloyd Sheen
May 25 '07 #7
Hi,

Is there any way we can use mouse-over-button event instead button-click
event? What i want to do is instead let user click button to pop up message i
let user put mouse over button and then auto-pop up message?

Thanks,
Martin

"Lloyd Sheen" wrote:
>
"martin1" <ma*****@discussions.microsoft.comwrote in message
news:09**********************************@microsof t.com...
Thank you! Seth Rowe

What I want to do is let user click each button to pop up message which is
related to StatusDesc field of Sysstat Table, the message is dynamic. The
problem (look at code below) is StatusDesc message is overwritten by next
loop, so how to keep statusDesc message for each button?

The Code like:
---------------------------------------------------
Pub Class _Default
Dim StatusDesc As String

Private Sub Form_Load(sender As Object, e As EventArgs)

For Each row In dtSysstat.Rows ' loop each record of sysstat table
Dim button As New Button ' create button for each row

btnText = Trim(row.Item("ButtonName")) ' get ButtonName
from table
StatusDesc = Trim(row.Item("StatusDesc").ToString) 'get
StatusDesc

button.Text = btnText
panel.Controls.Add(button)

' add click event to button
AddHandler button.Click, AddressOf Button_click
End Sub

Private Sub Button_Click(sender As Object, e As EventArgs)
MsgBox(StatusDesc)
End Sub

End Class
------------------------------------------------
Thank you again,
Martin
"rowe_newsgroups" wrote:
On May 24, 1:36 pm, martin1 <mart...@discussions.microsoft.comwrote:
Hi, Seth Rowe,

could you give sample on how to use addhandler,

Thanks,
martin

"rowe_newsgroups" wrote:
On May 24, 12:53 pm, martin1 <mart...@discussions.microsoft.com>
wrote:
Hi, All,

I create button in the code ( Dim Button as new Button), not using
button
web component (means not drap button and drop it ont he webform),
after that
I try to use button_click event, it is not work, anyone can tell
how to use
button click event ?

Thanks in advance,
Martin

AddHandler

Thanks,

Seth Rowe

Private Sub Form_Load(sender As Object, e As EventArgs)
Dim btn as new Button()
AddHandler btn.Click, AddressOf Button_Click
End Sub

Private Sub Button_Click(sender As Object, e As EventArgs)
' Do something useful
End Sub

Thanks,

Seth Rowe


When you create the button, set btn.tag = StatusDesc. Then when you handle
the click event you can cast the sender to a button and retrieve the tag as
the description.

Hope this helps

Lloyd Sheen
May 30 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: yfng | last post by:
In a web form, I want the user clicks on one button and this button will trigger another button/link which will open a new browser window? How to do that? Is there any method like...
2
by: Liqun Xu | last post by:
Hallo NG, I created a Button with Click-Event dynamically: System.Web.UI.WebControls.Button bt_1 = new Button(); bt_1.Click += new EventHandler(bt_1_click); and I implemented the Funktion...
6
by: Michael Johnson Jr. | last post by:
I am trying to handle a button click event, which updates a web control table with data. The button is dynamically created in the table itself. When I call updateTable() in the Page_Load the new...
4
by: Mark Lingen | last post by:
I've found a problem with postback event handling and webcontrol buttons. Try out the following code in an ASP.Net project and you will see. Create a web project in VB.Net and drop this code...
11
by: CW | last post by:
I have message entry screen that's causing me a bit of an issue. At the moment, there are 2 buttons, one is used to send message to another user (btnSend) and another is used to send messages to...
3
by: Imran Aziz | last post by:
Hello All, I have a search text and button that post data and my button handler filters the repeater control. However when the button is clicked the first time. The page_load event is being called...
7
by: MgGuigg | last post by:
Hello all, This is my first time posting a question to this forum, so here is hoping I am following protocol. I am scraping the rust off my old Basic programming skills, and have just recently...
15
by: Oleg Subachev | last post by:
I need to programmatically invoke from other class Click event of the Button on my Form. Button.OnClick method is protected, not public. How to perform this ? Oleg Subachev
3
by: GauravGupta | last post by:
i want to know that is it posible to call button click event before page load event on post back.... please help me....
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.