473,785 Members | 2,641 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic linkbutton event doesn't fire

hn
Hi,

I have linkbuttons created dynamically and they display fine on the web
page. However, when I click on the those link buttons, the event doesn't fire.

Please tell me what's wrong with the following code. Thanks.

Dim lbtnQuestion As LinkButton = New LinkButton
lbtnQuestion.Te xt = "Question " & (j + 1).ToString()

lbtnQuestion.Co mmandArgument = j
AddHandler lbtnQuestion.Co mmand, AddressOf lbtnQuestion_Cl ick

............... ............... ............... ............... ............... .............
Private Sub lbtnQuestion_Cl ick(ByVal sender As Object, ByVal e As
CommandEventArg s)

Response.Write( "Hey")

End Sub
Nov 18 '05 #1
2 3861
I tested ur code.
It works for me !!

post the complete code, see if u are checking ispostback ??
Because dyanmic controls needs to created on load everytime.
"hn" wrote:
Hi,

I have linkbuttons created dynamically and they display fine on the web
page. However, when I click on the those link buttons, the event doesn't fire.

Please tell me what's wrong with the following code. Thanks.

Dim lbtnQuestion As LinkButton = New LinkButton
lbtnQuestion.Te xt = "Question " & (j + 1).ToString()

lbtnQuestion.Co mmandArgument = j
AddHandler lbtnQuestion.Co mmand, AddressOf lbtnQuestion_Cl ick

............... ............... ............... ............... ............... ............
Private Sub lbtnQuestion_Cl ick(ByVal sender As Object, ByVal e As
CommandEventArg s)

Response.Write( "Hey")

End Sub

Nov 18 '05 #2
hn
Hi vinay,

Thank you for replying.

I have these linkbuttons created on certain occasions only, not always, so I
can't have them in ispostback or init. In most cases when the page is
postback, it should display something else, Only when this particular button
is clicked then the linkbuttons are created. All I want is when one of these
linkbuttons is clicked on, it redirects to a another page. Hmmm but you're
right, first comes the postback then comes the event, and the linkbutton is
gone during postback. I don't know how to deal with this.

"vinay" wrote:
I tested ur code.
It works for me !!

post the complete code, see if u are checking ispostback ??
Because dyanmic controls needs to created on load everytime.
"hn" wrote:
Hi,

I have linkbuttons created dynamically and they display fine on the web
page. However, when I click on the those link buttons, the event doesn't fire.

Please tell me what's wrong with the following code. Thanks.

Dim lbtnQuestion As LinkButton = New LinkButton
lbtnQuestion.Te xt = "Question " & (j + 1).ToString()

lbtnQuestion.Co mmandArgument = j
AddHandler lbtnQuestion.Co mmand, AddressOf lbtnQuestion_Cl ick

............... ............... ............... ............... ............... ............
Private Sub lbtnQuestion_Cl ick(ByVal sender As Object, ByVal e As
CommandEventArg s)

Response.Write( "Hey")

End Sub

Nov 18 '05 #3

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

Similar topics

1
5763
by: Mark | last post by:
I have two buttons in a DataGrid. If I leave the ButtonType = "LinkButton", the EditCommand and DeleteCommand events fire fine. If I change th ButtonType = "PushButton", the events do not fire. Does this buttonType property change how the events fire? Suggestions? I have the ItemCommand event wired up to, but that only fires for the LinkButton as well. A few code samples below ... Thanks!
0
1098
by: Glenn Owens | last post by:
OK, this should be simple but... I have a dynamically created DataGrid (which is a Composite Server Control that I've written - inheriting from the System.Web.UI.Webcontrols.DataGrid). The grid has been populated exclusively with template columns. One of the columns is a LinkButton. I want to be able to detect when the user selects the DataGridItem (row) and what item (row) has been selected. Subsequently I want to raise a new event to...
10
2856
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...
5
1819
by: Steve Harclerode | last post by:
Here's some code that I'm using to create a simple list of logical drive letters (my web application impersonates a user). I'm finding that my event handler doesn't fire. Can anyone give me a hint as to why it doesn't work? It's nearly a copy of some sample code that I lifted from a friend, whose code works (so he says!). By the way, I'm using a dotnet Table control in the ASPX page which starts off empty, it's ID is dirTable. By the...
2
1541
by: Shiju Poyilil | last post by:
I have a link button "lButton" created dynamically at the item databound event of the data grid "datagrid1" in the footer.so i want to execute the item command event of the datagrid on clicking the dynamicaly created link button, but when at runtime i click the dymanic created control it disapears from the datagrid footer and then it doesnt fire the itemcommand event of the datagrid. I am pasting below the pieces of my code for your...
4
10611
by: Fueled | last post by:
Hi everyone! I've made quite a lot of research on this, and I've tried a couple of proposed solutions. Nothing has worked for me, but I feel there's not much I'm missing. So I'm turning to this group and its experts for answers. So : - I've got a main page (main.aspx) - On this page, I've got a button (btnArchive), on whose click I dynamically add a UserControl (archive.ascx) to the main page.
13
10185
by: rn5a | last post by:
In a shopping cart app, suppose a user has placed 5 orders, I want to show him 5 LinkButtons (one for each order) so that when he clicks the first LinkButton, he would be shown the details of his first order. Likewise if he clicks the second LinkButton, he will be shown the details of the second order he had placed. The Text of the LinkButtons will be 1 2 3 etc. So this user would see 1 2 3 4 5 as the LinkButtons. The problem is...
4
7632
by: marty | last post by:
Having trouble creating a dynamic pagertemplate. I want it like this "Prev 1 2 3 4 Next". The numerically portion being the dynamic part based on the record count. I can generate it, but can't get any events to fire. Is it possible to do? I've tried creating them int he RowCreated event, DataBound and my own PagerTemplate, but nothing seems to work.
2
1760
by: rsdev | last post by:
Hi, I am dynamically creating controls as part of a paging system for a grid view in an updatepanel. I have attached a CommandEventHandler to the control. So far so good! But when a click on the Dynamic control (LinkButton) first time it doesn't fire the event. I have read the page DOM and it seems that the button changes ID after the first click and then stays the same. Why does the ID change? And is this the reason it doesn't...
0
9645
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
10325
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...
0
10148
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6740
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
5381
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
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
3646
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.