473,396 Members | 1,755 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,396 software developers and data experts.

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.Text = "Question " & (j + 1).ToString()

lbtnQuestion.CommandArgument = j
AddHandler lbtnQuestion.Command, AddressOf lbtnQuestion_Click

.................................................. ......................................
Private Sub lbtnQuestion_Click(ByVal sender As Object, ByVal e As
CommandEventArgs)

Response.Write("Hey")

End Sub
Nov 18 '05 #1
2 3847
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.Text = "Question " & (j + 1).ToString()

lbtnQuestion.CommandArgument = j
AddHandler lbtnQuestion.Command, AddressOf lbtnQuestion_Click

.................................................. .....................................
Private Sub lbtnQuestion_Click(ByVal sender As Object, ByVal e As
CommandEventArgs)

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.Text = "Question " & (j + 1).ToString()

lbtnQuestion.CommandArgument = j
AddHandler lbtnQuestion.Command, AddressOf lbtnQuestion_Click

.................................................. .....................................
Private Sub lbtnQuestion_Click(ByVal sender As Object, ByVal e As
CommandEventArgs)

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
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. ...
0
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...
10
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...
5
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...
2
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...
4
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...
13
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...
4
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...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...
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
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,...

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.