473,669 Members | 2,395 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I create a Linkbutton and Event Hander on the fly ?

Hi,

I am wanting to create Linkbuttons and Event Handlers on the fly.

Ideally I would be able to pass the CommandName and CommandArgument to the
Event Handler which in turn would pass these to a generic method for
processing.

I have been able to create the LinkButtons themselves on the fly. However I
haven't managed to connect the to an Event Handler.

Regards

James.

Nov 17 '05 #1
6 1934
Good question
I would love to know the answer to this too.

The thing is that I am not sure if dynamically created controls can be
referenced properly in the code behind page. What i mean is if you
dynamically created something like System.Web.UI.W ebControls.Text Box
text01; , I don't think you'll be able to get the compiler to compile when
you try to reference text01 in your static code, similarly eventhandlers are
attached to any particular static control on your page. So i am not sure
what you are trying to do is possible. although it would make more sense
that it should be possible.

Call in the experts....

Cheers

J


"James Norton-Jones" <ja************ ****@stopford.c om> wrote in message
news:3f******** *************** @news.easynet.c o.uk...
Hi,

I am wanting to create Linkbuttons and Event Handlers on the fly.

Ideally I would be able to pass the CommandName and CommandArgument to the
Event Handler which in turn would pass these to a generic method for
processing.

I have been able to create the LinkButtons themselves on the fly. However I haven't managed to connect the to an Event Handler.

Regards

James.


Nov 17 '05 #2
Good question
I would love to know the answer to this too.

The thing is that I am not sure if dynamically created controls can be
referenced properly in the code behind page. What i mean is if you
dynamically created something like System.Web.UI.W ebControls.Text Box
text01; , I don't think you'll be able to get the compiler to compile when
you try to reference text01 in your static code, similarly eventhandlers are
attached to any particular static control on your page. So i am not sure
what you are trying to do is possible. although it would make more sense
that it should be possible.

Call in the experts....

Cheers

J


"James Norton-Jones" <ja************ ****@stopford.c om> wrote in message
news:3f******** *************** @news.easynet.c o.uk...
Hi,

I am wanting to create Linkbuttons and Event Handlers on the fly.

Ideally I would be able to pass the CommandName and CommandArgument to the
Event Handler which in turn would pass these to a generic method for
processing.

I have been able to create the LinkButtons themselves on the fly. However I haven't managed to connect the to an Event Handler.

Regards

James.


Nov 17 '05 #3
Have a look at my previous posting 'Programaticall y creating Linkbuttons but
....'
Which dynamically create the controls but does not handle any events.
"James Zhuo" <na************ **@optusnet.com .au> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Good question
I would love to know the answer to this too.

The thing is that I am not sure if dynamically created controls can be
referenced properly in the code behind page. What i mean is if you
dynamically created something like System.Web.UI.W ebControls.Text Box
text01; , I don't think you'll be able to get the compiler to compile when
you try to reference text01 in your static code, similarly eventhandlers are attached to any particular static control on your page. So i am not sure
what you are trying to do is possible. although it would make more sense
that it should be possible.

Call in the experts....

Cheers

J


"James Norton-Jones" <ja************ ****@stopford.c om> wrote in message
news:3f******** *************** @news.easynet.c o.uk...
Hi,

I am wanting to create Linkbuttons and Event Handlers on the fly.

Ideally I would be able to pass the CommandName and CommandArgument to the Event Handler which in turn would pass these to a generic method for
processing.

I have been able to create the LinkButtons themselves on the fly.
However I
haven't managed to connect the to an Event Handler.

Regards

James.



Nov 17 '05 #4
Have a look at my previous posting 'Programaticall y creating Linkbuttons but
....'
Which dynamically create the controls but does not handle any events.
"James Zhuo" <na************ **@optusnet.com .au> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Good question
I would love to know the answer to this too.

The thing is that I am not sure if dynamically created controls can be
referenced properly in the code behind page. What i mean is if you
dynamically created something like System.Web.UI.W ebControls.Text Box
text01; , I don't think you'll be able to get the compiler to compile when
you try to reference text01 in your static code, similarly eventhandlers are attached to any particular static control on your page. So i am not sure
what you are trying to do is possible. although it would make more sense
that it should be possible.

Call in the experts....

Cheers

J


"James Norton-Jones" <ja************ ****@stopford.c om> wrote in message
news:3f******** *************** @news.easynet.c o.uk...
Hi,

I am wanting to create Linkbuttons and Event Handlers on the fly.

Ideally I would be able to pass the CommandName and CommandArgument to the Event Handler which in turn would pass these to a generic method for
processing.

I have been able to create the LinkButtons themselves on the fly.
However I
haven't managed to connect the to an Event Handler.

Regards

James.



Nov 17 '05 #5
As it turns out this is quite easy ie:

lbButton = New LinkButton

lbButton.Text = "Edit"

lbButton.Comman dName = lbButton.Text

lbButton.Comman dArgument = rs.Fields("Id") .Value

AddHandler lbButton.Comman d, AddressOf Me.LinkButton_C ommand

"James Norton-Jones" <ja************ ****@stopford.c om> wrote in message
news:3f******** *************** @news.easynet.c o.uk...
Hi,

I am wanting to create Linkbuttons and Event Handlers on the fly.

Ideally I would be able to pass the CommandName and CommandArgument to the
Event Handler which in turn would pass these to a generic method for
processing.

I have been able to create the LinkButtons themselves on the fly. However I haven't managed to connect the to an Event Handler.

Regards

James.


Nov 17 '05 #6
Thanx for posting back James
This should come in handy later on.

Cheers

James

"James Norton-Jones" <ja************ ****@stopford.c om> wrote in message
news:3f******** *************** @news.easynet.c o.uk...
As it turns out this is quite easy ie:

lbButton = New LinkButton

lbButton.Text = "Edit"

lbButton.Comman dName = lbButton.Text

lbButton.Comman dArgument = rs.Fields("Id") .Value

AddHandler lbButton.Comman d, AddressOf Me.LinkButton_C ommand

"James Norton-Jones" <ja************ ****@stopford.c om> wrote in message
news:3f******** *************** @news.easynet.c o.uk...
Hi,

I am wanting to create Linkbuttons and Event Handlers on the fly.

Ideally I would be able to pass the CommandName and CommandArgument to the Event Handler which in turn would pass these to a generic method for
processing.

I have been able to create the LinkButtons themselves on the fly.
However I
haven't managed to connect the to an Event Handler.

Regards

James.



Nov 17 '05 #7

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

Similar topics

3
10796
by: Kiyomi | last post by:
Hello, I create a Table1 dynamically at run time, and at the same time, I would like to create LinkButton controls, also dynamically, and insert them into each line in my Table1. I would then like that, when clicking the LinkButton, the user can be navigated to another page, carrying a variable. I would like to use server.transfer method instead of QueryString as I don't want the carried variable to be visible for the user.
3
1792
by: leon | last post by:
hello friends, i am writing a page aspx and creating controls dinamicaly and then i must to create for each control the events as well. Anybody to know how????? happy day lion
3
23189
by: CodeRazor | last post by:
Hi, I am trying to dynamically create linkbuttons. They need an event handler, so i can respond to the user's click. I try to add the eventhandler on the fly, but when i click on the link, the code does not execute, it just reloads the page. Where am i going so wrong? i don't understand what's missing. many thanks in advance.
1
11569
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at http://weblogs.asp.net/asmith/archive/2003/09/15/27684.aspx but it was far more complex then I needed. (I got lost trying to figure it all out). Therefore, here goes my simple "web dialog box with parent event handler fireing" solution. ...
10
2845
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I have to add a datalist control. Using this datalist control I should be able to add edit, modify and cancel the items listed in this control. Here is how I designed. I used placeholder to add the controls dynamically to the page on the click...
1
2161
by: smash2004 | last post by:
I have VS 2005 CTP. I created a page with one repeater. Inside i put a linkbutton. Usually when i put linkbutton on a page I doubleclick it in designview and event gets created in codebehind file. Now i can't click on anything because my linkbutton is not visible in the designer. So i moved my linkbutton outside the repeater and doubleclicked it and code gets created. With code created I moved my linkbutton again inside
2
10774
by: msnews.microsoft.com | last post by:
I want to read information out of a database at runtime (names of files available to download) and create a list of linkbuttons that the user can click on to download the file(s). How can I accomplish this. I've got this far: In the html: .... table>
1
2310
by: geronimi | last post by:
I want to create a linkbutton in a cell because not every row needs one (so I can't setup a linkbuttoncolumn instead of a boundcolumn.) First, i create a linkbutton in the datagrid_ItemDataBound : Dim linkButton As New LinkButton linkButton.Text = name linkButton.CommandName = "PassSelectedClient" linkButton.CommandArgument = id I add it to the controls
1
1674
by: kaczmar2 | last post by:
I have an ASP.NET page where controls are created dynamically, and I have an issue where one event handler creates another set of controls, and then adds event handlers to those controls. The problem comes in where I need to raise the event in the second control - the event does not fire. I have distilled the example below down to it simplest: on Page_Load one button is created, and a Click event hander is added to the button. When...
0
8465
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...
1
8588
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,...
0
8658
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4206
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...
0
4386
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2797
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
2032
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1788
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.