473,408 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

how to handle click event of the dynamically created button

hi
i am developing a web page in asp.net(VB)
here i have dynamicaaly created a button.
i have created this button in a procedure so that i can call it at varied places.
however, i am not able to handle click event of this button.
i have already made use of add handler...n had followed all the convention required.But on clicking the button the control goes to the page_load but not on the delegate function.please help
i am also pasting part of the code i have written

Sub populateButton(ByVal flag As String)

Dim table As New Literal
Dim ctable As New Literal
Dim td As New Literal
Dim tdrigth As New Literal
Dim ctd As New Literal
Dim tr As New Literal
Dim ctr As New Literal
Dim myBreak As New Literal


table.Text = "<table width=100% border=0 bgcolor=beige >"
ctable.Text = "</table>"
td.Text = "<td>"
ctd.Text = "</td>"
tr.Text = "<tr>"
ctr.Text = "</tr>"
tdrigth.Text = "<td align=right>"
'MyBreak.Text = "<table><tr><td bgcolor=beige align=center width=100%>"
Dim btntable As New Literal
btntable.Text = "<table border=0 width=100% bgcolor=beige><tr align=center><td>"
Dim recN As New Literal


Dim btnsubmit As New Button
btnsubmit.Text = "SUBMIT"
AddHandler btnsubmit.Click, AddressOf btnsubmitClick
btnsubmit.ID = "btnsubmit"

Dim btncancel As New Button
btncancel.Text = "CANCEL"
btncancel.ID = "btncancel"
AddHandler btncancel.Click, AddressOf btncancelClick

' datagridarea.Controls.Add(btntable)

datagridarea.Controls.Add(table)
datagridarea.Controls.Add(tr)
datagridarea.Controls.Add(td)
datagridarea.Controls.Add(btncancel)
datagridarea.Controls.Add(ctd)
datagridarea.Controls.Add(tdrigth)
datagridarea.Controls.Add(btnsubmit)
datagridarea.Controls.Add(ctd)
datagridarea.Controls.Add(ctr)
datagridarea.Controls.Add(ctable)
End Sub

Private Sub btnsubmitClick(ByVal sender As Object, ByVal e As System.EventArgs)
Label1.Text = "aparnaa"
onchange(EventArgs.Empty)
End Sub
Private Sub btncancelClick(ByVal sender As Object, ByVal e As System.EventArgs)
Label1.Text = "apaaaaaarna"
End Sub
Protected Sub onchange(ByVal e As EventArgs)
RaiseEvent change(Me, e)
End Sub

Public Event change(ByVal sender As Object, ByVal e As EventArgs)






let me know if i am making sm mistake ...
thanks
aparna
Apr 10 '07 #1
0 3217

Sign in to post your reply or Sign up for a free account.

Similar topics

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...
2
by: Michael Ramey | last post by:
Howdy, I think I have a good question! I'm creating a usercontrol, and within this usercontrol, I'm dynamically creating controls (imagebuttons to be exact), that the user can click on which...
1
by: Earl Teigrob | last post by:
PROBLEM: When a user control is loaded into a PlaceHolder control more than once, the events do not fire on the first click of a control on the dynamically loaded user control. In other words, the...
1
by: ronaldo | last post by:
As title, I used the following code to create a button and assign the event handle dynamically. private sub showOrderList() ... Dim btnRemove As New Button btnRemove.ID = "r" & strMyProductId...
1
by: Lalit | last post by:
Hi, My application has two methods which creates buttons at runtime. In one method I am able to handle the events of the buttons created at run time, but in other I am not. The code structure...
15
by: Adam J. Schaff | last post by:
I have noticed that if a user closes a form via pressing return (either while the OK button has focus or if AcceptButton is set to OK for the form) then the "ENTER" keypress event fires ON THE...
4
by: Bob | last post by:
Hi, I'm working with VWD and i defined programmatically a button (in code-behind) with an ID. So I expect to see beside "Page Events" and "Form1" my button "b1" in order to use the Click event....
5
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created...
4
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi, I have built a custom control button which inherits from WebControl and implements IPostBackEventHandler. The control also declares an event Click and provides a method OnClick which invokes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.