473,763 Members | 9,161 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to handle click event of the dynamically created button

1 New Member
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><t d>"
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.Co ntrols.Add(btnt able)

datagridarea.Co ntrols.Add(tabl e)
datagridarea.Co ntrols.Add(tr)
datagridarea.Co ntrols.Add(td)
datagridarea.Co ntrols.Add(btnc ancel)
datagridarea.Co ntrols.Add(ctd)
datagridarea.Co ntrols.Add(tdri gth)
datagridarea.Co ntrols.Add(btns ubmit)
datagridarea.Co ntrols.Add(ctd)
datagridarea.Co ntrols.Add(ctr)
datagridarea.Co ntrols.Add(ctab le)
End Sub

Private Sub btnsubmitClick( ByVal sender As Object, ByVal e As System.EventArg s)
Label1.Text = "aparnaa"
onchange(EventA rgs.Empty)
End Sub
Private Sub btncancelClick( ByVal sender As Object, ByVal e As System.EventArg s)
Label1.Text = "apaaaaaarn a"
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 3241

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

Similar topics

2
2356
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 bt_1_click in which I created a second Button dynamically too. System.Web.UI.WebControls.Button bt_2= new Button();
2
4227
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 will cause a postback to occur. My problem is, I can't seem to be able to get the handlers to work within the user control, to determine which control has been clicked, and what to do with it from there.
1
8167
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 first time the control is dynamically loaded, everything works fine. After that, if the control is loaded again from the page button event handler, the user controls events fail to fire on the first click NOTE: I (believe I) am rebuilding all...
1
3059
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 btnRemove.Text = "Remove" btnRemove.Attributes("style") ="font-family:arial;font-size:8pt"
1
1536
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 is as follows: page_load {
15
4055
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 CALLING FORM! This is very bad for me, because in my application, Form1 responds to an ENTER keypress by calling Form2. If the user closes Form2 via an ENTER, then Form1 just reopens it again, kind of trapping the user in Form2 (they can still close...
4
8471
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. But it doesnt' appear. After saving the code-behind file, i only see "Page Events" and "Form1". If i define the button declarativally, i see it. But i need to define it programmatically. Can anybody tell me how to do? I also tried with...
5
6760
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 link buttons to stay wired up to their click events. I have what is basically a simply survey question generation page. The page first displays a few static fields and a dropdownlist of various options for the user to select. When the user...
4
2529
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 the registered delegate. All is fine with my control until I try to add it to the page dynamically in a code behind event handler and wire-up the click event using the normal syntax such that; protected void btnNew_Click(object sender, EventArgs...
0
9564
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9387
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10148
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9938
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7368
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3528
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2794
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.