473,569 Members | 2,793 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AddHandler not working

I have a section of my code that dynamically creates LinkButtons to allow
the user to go to the page containing a question they have not answered. The
code that creates the LinkButton is called, as well as the AddHandler line
(I ran a Debug and saw that it executes this code, and the links are
displayed on the page afterwards). However, the eventhandler is not called
when the LinkButton is clicked. Here is the code that dynamically generates
the LinkButtons as well as the eventhandler I want to be called:
'The code that generates the LinkButtons:
Private Sub btnSubmit_Click (ByVal sender As Object, ByVal e As
System.Web.UI.I mageClickEventA rgs) Handles btnSubmit.Click
Me.submitanswer s()
If Me.completetest () Then
'Code that I use to update my database, not involved in this
problem because Me.completetest () returns false
Else
Me.lblAnswered. Text = String.Format(" {0} of 75 Questions
Answered (Not Answered: ", CStr(Me.questio nsanswered()))
Dim myconnection As New
SqlConnection(S ystem.Configura tion.Configurat ionManager.AppS ettings("connec tionstring"))
Dim cmd As New SqlCommand("", myconnection)
Dim qnumreader As SqlDataReader
Dim insertafter As Integer =
Me.Form.Control s.IndexOf(Me.lb lAnswered) + 1
For i As Integer = 1 To 75
cmd.CommandText = String.Format(" SELECT
questions.quest ionnumber FROM useranswers INNER JOIN questions ON
useranswers.que stionid=questio ns.questionid WHERE
questions.quest ionnumber={0} AND useranswers.tes tid={1} AND
useranswers.use rid={2}", i, CStr(Session("t estid")),
CStr(Session("u serid")))
myconnection.Op en()
qnumreader = cmd.ExecuteRead er()
If Not qnumreader.Read () Then
Dim questionlink As New LinkButton()
questionlink.Ca usesValidation = False
questionlink.Co mmandArgument = i
questionlink.Cs sClass = "answerRED"
questionlink.En ableViewState = False
questionlink.Te xt = i & " "
AddHandler questionlink.Co mmand, AddressOf
Me.QuestionLink Command
Me.Form.Control s.AddAt(inserta fter, questionlink)
insertafter += 1
End If
myconnection.Cl ose()
Next
Me.lblClosePare n.Visible = True
End If
End Sub

'The eventhandler I want to use:
Private Sub QuestionLinkCom mand(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Comm andEventArgs)
Dim myconnection As New
SqlConnection(S ystem.Configura tion.Configurat ionManager.AppS ettings("connec tionstring"))
Dim cmd As New SqlCommand("SEL ECT subgroupid FROM questions WHERE
questionnumber= " & e.CommandArgume nt, myconnection)
myconnection.Op en()
Session("subgro upid") = CInt(cmd.Execut eScalar())
myconnection.Cl ose()
End Sub
When I run my Application, the code in btnSubmit_Click works as I expect (or
at least it looks like it did), but when I click the dynamically created
LinkButtons (variable name questionlink), they postback but do not trigger
the QuestionLinkCom mand method (the QuestionLinkCom mand never gets executed
when I do a debug session). I cannot figure out why they are not triggering
this eventhandler, because I use AddHandler statements when creating the
LinkButtons, and the eventhandler has the correct signature. Is there
something I am doing wrong? Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/
Oct 2 '07 #1
15 2049
Try changing the line

Dim questionlink As New LinkButton()

to

Dim WithEvents questionlink As New LinkButton()

Does that work?
"Nathan Sokalski" wrote:
I have a section of my code that dynamically creates LinkButtons to allow
the user to go to the page containing a question they have not answered. The
code that creates the LinkButton is called, as well as the AddHandler line
(I ran a Debug and saw that it executes this code, and the links are
displayed on the page afterwards). However, the eventhandler is not called
when the LinkButton is clicked. Here is the code that dynamically generates
the LinkButtons as well as the eventhandler I want to be called:
'The code that generates the LinkButtons:
Private Sub btnSubmit_Click (ByVal sender As Object, ByVal e As
System.Web.UI.I mageClickEventA rgs) Handles btnSubmit.Click
Me.submitanswer s()
If Me.completetest () Then
'Code that I use to update my database, not involved in this
problem because Me.completetest () returns false
Else
Me.lblAnswered. Text = String.Format(" {0} of 75 Questions
Answered (Not Answered: ", CStr(Me.questio nsanswered()))
Dim myconnection As New
SqlConnection(S ystem.Configura tion.Configurat ionManager.AppS ettings("connec tionstring"))
Dim cmd As New SqlCommand("", myconnection)
Dim qnumreader As SqlDataReader
Dim insertafter As Integer =
Me.Form.Control s.IndexOf(Me.lb lAnswered) + 1
For i As Integer = 1 To 75
cmd.CommandText = String.Format(" SELECT
questions.quest ionnumber FROM useranswers INNER JOIN questions ON
useranswers.que stionid=questio ns.questionid WHERE
questions.quest ionnumber={0} AND useranswers.tes tid={1} AND
useranswers.use rid={2}", i, CStr(Session("t estid")),
CStr(Session("u serid")))
myconnection.Op en()
qnumreader = cmd.ExecuteRead er()
If Not qnumreader.Read () Then
Dim questionlink As New LinkButton()
questionlink.Ca usesValidation = False
questionlink.Co mmandArgument = i
questionlink.Cs sClass = "answerRED"
questionlink.En ableViewState = False
questionlink.Te xt = i & " "
AddHandler questionlink.Co mmand, AddressOf
Me.QuestionLink Command
Me.Form.Control s.AddAt(inserta fter, questionlink)
insertafter += 1
End If
myconnection.Cl ose()
Next
Me.lblClosePare n.Visible = True
End If
End Sub

'The eventhandler I want to use:
Private Sub QuestionLinkCom mand(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Comm andEventArgs)
Dim myconnection As New
SqlConnection(S ystem.Configura tion.Configurat ionManager.AppS ettings("connec tionstring"))
Dim cmd As New SqlCommand("SEL ECT subgroupid FROM questions WHERE
questionnumber= " & e.CommandArgume nt, myconnection)
myconnection.Op en()
Session("subgro upid") = CInt(cmd.Execut eScalar())
myconnection.Cl ose()
End Sub
When I run my Application, the code in btnSubmit_Click works as I expect (or
at least it looks like it did), but when I click the dynamically created
LinkButtons (variable name questionlink), they postback but do not trigger
the QuestionLinkCom mand method (the QuestionLinkCom mand never gets executed
when I do a debug session). I cannot figure out why they are not triggering
this eventhandler, because I use AddHandler statements when creating the
LinkButtons, and the eventhandler has the correct signature. Is there
something I am doing wrong? Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/
Oct 2 '07 #2
No, if I add the WithEvents keyword I recieve the message:

'WithEvents' is not valid on a local variable declaration.

That was a good suggestion (when I read your reply I thought that might be
it), but unfortunately it wasn't. Any other ideas? Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"Charlie" <c2****@yahoo.c omwrote in message
news:43******** *************** ***********@mic rosoft.com...
Try changing the line

Dim questionlink As New LinkButton()

to

Dim WithEvents questionlink As New LinkButton()

Does that work?
"Nathan Sokalski" wrote:
>I have a section of my code that dynamically creates LinkButtons to allow
the user to go to the page containing a question they have not answered.
The
code that creates the LinkButton is called, as well as the AddHandler
line
(I ran a Debug and saw that it executes this code, and the links are
displayed on the page afterwards). However, the eventhandler is not
called
when the LinkButton is clicked. Here is the code that dynamically
generates
the LinkButtons as well as the eventhandler I want to be called:
'The code that generates the LinkButtons:
Private Sub btnSubmit_Click (ByVal sender As Object, ByVal e As
System.Web.UI. ImageClickEvent Args) Handles btnSubmit.Click
Me.submitanswer s()
If Me.completetest () Then
'Code that I use to update my database, not involved in this
problem because Me.completetest () returns false
Else
Me.lblAnswered. Text = String.Format(" {0} of 75 Questions
Answered (Not Answered: ", CStr(Me.questio nsanswered()))
Dim myconnection As New
SqlConnection( System.Configur ation.Configura tionManager.App Settings("conne ctionstring"))
Dim cmd As New SqlCommand("", myconnection)
Dim qnumreader As SqlDataReader
Dim insertafter As Integer =
Me.Form.Contro ls.IndexOf(Me.l blAnswered) + 1
For i As Integer = 1 To 75
cmd.CommandText = String.Format(" SELECT
questions.ques tionnumber FROM useranswers INNER JOIN questions ON
useranswers.qu estionid=questi ons.questionid WHERE
questions.ques tionnumber={0} AND useranswers.tes tid={1} AND
useranswers.us erid={2}", i, CStr(Session("t estid")),
CStr(Session(" userid")))
myconnection.Op en()
qnumreader = cmd.ExecuteRead er()
If Not qnumreader.Read () Then
Dim questionlink As New LinkButton()
questionlink.Ca usesValidation = False
questionlink.Co mmandArgument = i
questionlink.Cs sClass = "answerRED"
questionlink.En ableViewState = False
questionlink.Te xt = i & " "
AddHandler questionlink.Co mmand, AddressOf
Me.QuestionLin kCommand
Me.Form.Control s.AddAt(inserta fter, questionlink)
insertafter += 1
End If
myconnection.Cl ose()
Next
Me.lblClosePare n.Visible = True
End If
End Sub

'The eventhandler I want to use:
Private Sub QuestionLinkCom mand(ByVal sender As Object, ByVal e As
System.Web.UI. WebControls.Com mandEventArgs)
Dim myconnection As New
SqlConnection( System.Configur ation.Configura tionManager.App Settings("conne ctionstring"))
Dim cmd As New SqlCommand("SEL ECT subgroupid FROM questions WHERE
questionnumber =" & e.CommandArgume nt, myconnection)
myconnection.Op en()
Session("subgro upid") = CInt(cmd.Execut eScalar())
myconnection.Cl ose()
End Sub
When I run my Application, the code in btnSubmit_Click works as I expect
(or
at least it looks like it did), but when I click the dynamically created
LinkButtons (variable name questionlink), they postback but do not
trigger
the QuestionLinkCom mand method (the QuestionLinkCom mand never gets
executed
when I do a debug session). I cannot figure out why they are not
triggering
this eventhandler, because I use AddHandler statements when creating the
LinkButtons, and the eventhandler has the correct signature. Is there
something I am doing wrong? Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

Oct 2 '07 #3
Put the declaration of questionlink outside of the btnSubmit_Click code
block, in the general declarations area...

public withevents questionlink as New LinkButton()
inside your codeblock, remove the dim questionlink line.

you could also scope the linkbutton as public or friend.

does that work?

"Nathan Sokalski" wrote:
No, if I add the WithEvents keyword I recieve the message:

'WithEvents' is not valid on a local variable declaration.

That was a good suggestion (when I read your reply I thought that might be
it), but unfortunately it wasn't. Any other ideas? Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"Charlie" <c2****@yahoo.c omwrote in message
news:43******** *************** ***********@mic rosoft.com...
Try changing the line

Dim questionlink As New LinkButton()

to

Dim WithEvents questionlink As New LinkButton()

Does that work?
"Nathan Sokalski" wrote:
I have a section of my code that dynamically creates LinkButtons to allow
the user to go to the page containing a question they have not answered.
The
code that creates the LinkButton is called, as well as the AddHandler
line
(I ran a Debug and saw that it executes this code, and the links are
displayed on the page afterwards). However, the eventhandler is not
called
when the LinkButton is clicked. Here is the code that dynamically
generates
the LinkButtons as well as the eventhandler I want to be called:
'The code that generates the LinkButtons:
Private Sub btnSubmit_Click (ByVal sender As Object, ByVal e As
System.Web.UI.I mageClickEventA rgs) Handles btnSubmit.Click
Me.submitanswer s()
If Me.completetest () Then
'Code that I use to update my database, not involved in this
problem because Me.completetest () returns false
Else
Me.lblAnswered. Text = String.Format(" {0} of 75 Questions
Answered (Not Answered: ", CStr(Me.questio nsanswered()))
Dim myconnection As New
SqlConnection(S ystem.Configura tion.Configurat ionManager.AppS ettings("connec tionstring"))
Dim cmd As New SqlCommand("", myconnection)
Dim qnumreader As SqlDataReader
Dim insertafter As Integer =
Me.Form.Control s.IndexOf(Me.lb lAnswered) + 1
For i As Integer = 1 To 75
cmd.CommandText = String.Format(" SELECT
questions.quest ionnumber FROM useranswers INNER JOIN questions ON
useranswers.que stionid=questio ns.questionid WHERE
questions.quest ionnumber={0} AND useranswers.tes tid={1} AND
useranswers.use rid={2}", i, CStr(Session("t estid")),
CStr(Session("u serid")))
myconnection.Op en()
qnumreader = cmd.ExecuteRead er()
If Not qnumreader.Read () Then
Dim questionlink As New LinkButton()
questionlink.Ca usesValidation = False
questionlink.Co mmandArgument = i
questionlink.Cs sClass = "answerRED"
questionlink.En ableViewState = False
questionlink.Te xt = i & " "
AddHandler questionlink.Co mmand, AddressOf
Me.QuestionLink Command
Me.Form.Control s.AddAt(inserta fter, questionlink)
insertafter += 1
End If
myconnection.Cl ose()
Next
Me.lblClosePare n.Visible = True
End If
End Sub

'The eventhandler I want to use:
Private Sub QuestionLinkCom mand(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Comm andEventArgs)
Dim myconnection As New
SqlConnection(S ystem.Configura tion.Configurat ionManager.AppS ettings("connec tionstring"))
Dim cmd As New SqlCommand("SEL ECT subgroupid FROM questions WHERE
questionnumber= " & e.CommandArgume nt, myconnection)
myconnection.Op en()
Session("subgro upid") = CInt(cmd.Execut eScalar())
myconnection.Cl ose()
End Sub
When I run my Application, the code in btnSubmit_Click works as I expect
(or
at least it looks like it did), but when I click the dynamically created
LinkButtons (variable name questionlink), they postback but do not
trigger
the QuestionLinkCom mand method (the QuestionLinkCom mand never gets
executed
when I do a debug session). I cannot figure out why they are not
triggering
this eventhandler, because I use AddHandler statements when creating the
LinkButtons, and the eventhandler has the correct signature. Is there
something I am doing wrong? Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/


Oct 2 '07 #4
Nathan,

Here is a simple sample of dynamicly creating textboxes with events.

Will you be so kind if you send next time problems to these newsgroup to
show a simple sample instead of almost a complete sample. We want to help
you, however not doing a daytime job by investigating parts which are not
relevant to your question.

Cor

Oct 2 '07 #5
On Oct 1, 9:38 pm, "Nathan Sokalski" <njsokal...@hot mail.comwrote:
I have a section of my code that dynamically creates LinkButtons to allow
the user to go to the page containing a question they have not answered. The
code that creates the LinkButton is called, as well as the AddHandler line
(I ran a Debug and saw that it executes this code, and the links are
displayed on the page afterwards). However, the eventhandler is not called
when the LinkButton is clicked. Here is the code that dynamically generates
the LinkButtons as well as the eventhandler I want to be called:

'The code that generates the LinkButtons:
Private Sub btnSubmit_Click (ByVal sender As Object, ByVal e As
System.Web.UI.I mageClickEventA rgs) Handles btnSubmit.Click
Me.submitanswer s()
If Me.completetest () Then
'Code that I use to update my database, not involved in this
problem because Me.completetest () returns false
Else
Me.lblAnswered. Text = String.Format(" {0} of 75 Questions
Answered (Not Answered: ", CStr(Me.questio nsanswered()))
Dim myconnection As New
SqlConnection(S ystem.Configura tion.Configurat ionManager.AppS ettings("connec tionstring"))
Dim cmd As New SqlCommand("", myconnection)
Dim qnumreader As SqlDataReader
Dim insertafter As Integer =
Me.Form.Control s.IndexOf(Me.lb lAnswered) + 1
For i As Integer = 1 To 75
cmd.CommandText = String.Format(" SELECT
questions.quest ionnumber FROM useranswers INNER JOIN questions ON
useranswers.que stionid=questio ns.questionid WHERE
questions.quest ionnumber={0} AND useranswers.tes tid={1} AND
useranswers.use rid={2}", i, CStr(Session("t estid")),
CStr(Session("u serid")))
myconnection.Op en()
qnumreader = cmd.ExecuteRead er()
If Not qnumreader.Read () Then
Dim questionlink As New LinkButton()
questionlink.Ca usesValidation = False
questionlink.Co mmandArgument = i
questionlink.Cs sClass = "answerRED"
questionlink.En ableViewState = False
questionlink.Te xt = i & " "
AddHandler questionlink.Co mmand, AddressOf
Me.QuestionLink Command
Me.Form.Control s.AddAt(inserta fter, questionlink)
insertafter += 1
End If
myconnection.Cl ose()
Next
Me.lblClosePare n.Visible = True
End If
End Sub

'The eventhandler I want to use:
Private Sub QuestionLinkCom mand(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Comm andEventArgs)
Dim myconnection As New
SqlConnection(S ystem.Configura tion.Configurat ionManager.AppS ettings("connec tionstring"))
Dim cmd As New SqlCommand("SEL ECT subgroupid FROM questions WHERE
questionnumber= " & e.CommandArgume nt, myconnection)
myconnection.Op en()
Session("subgro upid") = CInt(cmd.Execut eScalar())
myconnection.Cl ose()
End Sub

When I run my Application, the code in btnSubmit_Click works as I expect (or
at least it looks like it did), but when I click the dynamically created
LinkButtons (variable name questionlink), they postback but do not trigger
the QuestionLinkCom mand method (the QuestionLinkCom mand never gets executed
when I do a debug session). I cannot figure out why they are not triggering
this eventhandler, because I use AddHandler statements when creating the
LinkButtons, and the eventhandler has the correct signature. Is there
something I am doing wrong? Thanks.
--
Nathan Sokalski
njsokal...@hotm ail.comhttp://www.nathansokal ski.com/
You apparently aren't to familiar with the programming modal of
ASP.NET? You need to use AddHandler to add the event listener before
the child control's event are handled (like in the Load event of the
Page), otherwise the dynamic event won't exist when it's time to
process it.

By the way, if you search the newsgroups before posting you could find
the answer on your own....

http://groups.google.com/group/micro...rch+this+group

Thanks,

Seth Rowe

Oct 2 '07 #7
Nathan Sokalski wrote:
I have a section of my code that dynamically creates LinkButtons to
allow the user to go to the page containing a question they have not
answered. The code that creates the LinkButton is called, as well as
the AddHandler line (I ran a Debug and saw that it executes this
code, and the links are displayed on the page afterwards). However,
the eventhandler is not called when the LinkButton is clicked. Here
is the code that dynamically generates the LinkButtons as well as the
eventhandler I want to be called:
<snip>

You have to tell it to AutoPostBack. Incidentally, you can use "With" to
save a bit of typing:-
If Not qnumreader.Read () Then
Dim questionlink As New LinkButton()
With questionlink
.CausesValidati on = False
.CommandArgumen t = i
.CssClass = "answerRED"
.EnableViewStat e = False
.Text = i & "&nbsp;"
.AutoPostBack = True
End With
AddHandler questionlink.Co mmand, AddressOf
Me.QuestionLink Command
Me.Form.Control s.AddAt(inserta fter, questionlink)
insertafter += 1
End If
HTH

Andrew
Oct 2 '07 #8
This is a LinkButton, it does not need or have an AutoPostBack property. And
take note that in my original post I stated that it does do a PostBack, it
just doesn't trigger the eventhandler I attempted to assign it.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"Andrew Morton" <ak*@in-press.co.uk.inv alidwrote in message
news:u3******** ******@TK2MSFTN GP03.phx.gbl...
Nathan Sokalski wrote:
>I have a section of my code that dynamically creates LinkButtons to
allow the user to go to the page containing a question they have not
answered. The code that creates the LinkButton is called, as well as
the AddHandler line (I ran a Debug and saw that it executes this
code, and the links are displayed on the page afterwards). However,
the eventhandler is not called when the LinkButton is clicked. Here
is the code that dynamically generates the LinkButtons as well as the
eventhandler I want to be called:

<snip>

You have to tell it to AutoPostBack. Incidentally, you can use "With" to
save a bit of typing:-
> If Not qnumreader.Read () Then
Dim questionlink As New LinkButton()
With questionlink
.CausesValidati on = False
.CommandArgumen t = i
.CssClass = "answerRED"
.EnableViewStat e = False
.Text = i & "&nbsp;"
.AutoPostBack = True
End With
> AddHandler questionlink.Co mmand, AddressOf
Me.QuestionLin kCommand
Me.Form.Control s.AddAt(inserta fter, questionlink)
insertafter += 1
End If

HTH

Andrew

Oct 2 '07 #9
asp.net pages are stateless. you rendered the linkbuton and added to
handler on the click event. but when the user links on th button and the
asp.net is run again, the page does create th linkbutton and add the
handler, so the event is ignored.

your code needs to remember it added the linkbutton and handler during
previous postback and recreate the linkbutton and handler during the
oninit event. you can save your state in session or viewstate.

-- bruce (sqlwork.com)

Nathan Sokalski wrote:
I have a section of my code that dynamically creates LinkButtons to allow
the user to go to the page containing a question they have not answered. The
code that creates the LinkButton is called, as well as the AddHandler line
(I ran a Debug and saw that it executes this code, and the links are
displayed on the page afterwards). However, the eventhandler is not called
when the LinkButton is clicked. Here is the code that dynamically generates
the LinkButtons as well as the eventhandler I want to be called:
'The code that generates the LinkButtons:
Private Sub btnSubmit_Click (ByVal sender As Object, ByVal e As
System.Web.UI.I mageClickEventA rgs) Handles btnSubmit.Click
Me.submitanswer s()
If Me.completetest () Then
'Code that I use to update my database, not involved in this
problem because Me.completetest () returns false
Else
Me.lblAnswered. Text = String.Format(" {0} of 75 Questions
Answered (Not Answered: ", CStr(Me.questio nsanswered()))
Dim myconnection As New
SqlConnection(S ystem.Configura tion.Configurat ionManager.AppS ettings("connec tionstring"))
Dim cmd As New SqlCommand("", myconnection)
Dim qnumreader As SqlDataReader
Dim insertafter As Integer =
Me.Form.Control s.IndexOf(Me.lb lAnswered) + 1
For i As Integer = 1 To 75
cmd.CommandText = String.Format(" SELECT
questions.quest ionnumber FROM useranswers INNER JOIN questions ON
useranswers.que stionid=questio ns.questionid WHERE
questions.quest ionnumber={0} AND useranswers.tes tid={1} AND
useranswers.use rid={2}", i, CStr(Session("t estid")),
CStr(Session("u serid")))
myconnection.Op en()
qnumreader = cmd.ExecuteRead er()
If Not qnumreader.Read () Then
Dim questionlink As New LinkButton()
questionlink.Ca usesValidation = False
questionlink.Co mmandArgument = i
questionlink.Cs sClass = "answerRED"
questionlink.En ableViewState = False
questionlink.Te xt = i & "&nbsp;"
AddHandler questionlink.Co mmand, AddressOf
Me.QuestionLink Command
Me.Form.Control s.AddAt(inserta fter, questionlink)
insertafter += 1
End If
myconnection.Cl ose()
Next
Me.lblClosePare n.Visible = True
End If
End Sub

'The eventhandler I want to use:
Private Sub QuestionLinkCom mand(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Comm andEventArgs)
Dim myconnection As New
SqlConnection(S ystem.Configura tion.Configurat ionManager.AppS ettings("connec tionstring"))
Dim cmd As New SqlCommand("SEL ECT subgroupid FROM questions WHERE
questionnumber= " & e.CommandArgume nt, myconnection)
myconnection.Op en()
Session("subgro upid") = CInt(cmd.Execut eScalar())
myconnection.Cl ose()
End Sub
When I run my Application, the code in btnSubmit_Click works as I expect (or
at least it looks like it did), but when I click the dynamically created
LinkButtons (variable name questionlink), they postback but do not trigger
the QuestionLinkCom mand method (the QuestionLinkCom mand never gets executed
when I do a debug session). I cannot figure out why they are not triggering
this eventhandler, because I use AddHandler statements when creating the
LinkButtons, and the eventhandler has the correct signature. Is there
something I am doing wrong? Thanks.
Oct 2 '07 #10

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

Similar topics

2
5439
by: RA | last post by:
I have simpe code as follows. Private sub Page_load..... FillTable() End Sub Private Sub FillTable() '
2
2760
by: Just Me | last post by:
When a document is to be printed I call a method that contains an AddHandler statement. I just realized that if a second copy is to be printed the method is called and the AddHandler is executed again. Is doing AddHandler a second time wrong? I did check and even though I do AddHandler 3 times the handler is only called once.
10
5022
by: Rick Palmer | last post by:
I have an app I'm working on that will allow a user to run one of 5 reports. The report names are in a combobox on my form. I have a sub defined for each report that has the exact same name as is displayed in the combobox. I have one button on the form to start processing. What I want to do is this: When the user selects the report they...
6
9144
by: Carlo3030 | last post by:
Been reading Dino Esposito's Article "A DetailsView Control for ASP.NET 1.x" found in the msdn Library. His example was created using VB.NET. I am trying to convert the example (DetailsView control) to C#. The Issue is I converted this line (in VB): AddHandler _insertButton.Click, AddressOf OnApplyInsertMode to C#.NET with this:
3
1657
by: Vemund Halvorsen | last post by:
Hi, Im having some trouble getting Addhandler to work. Using withevents everything is working fine. But with AddHandler I get no callback. The code below works fin if I declare _tcp as a private class member (etc. Dim WithEvents mTcp as New MyTCP). Classes/modules; module Main, class MyCtrl and class MyTcp. Any tips why using...
5
2199
by: Slim | last post by:
i have a simple page, with one button button1. when click it creates a new button button 2 and adds a event handler to it. but when button 2 is clicked nothing happens, why? Partial Class test_buttons Inherits System.Web.UI.Page Dim bt2 As Button
15
7111
by: Nathan Sokalski | last post by:
I have a section of my code that dynamically creates LinkButtons to allow the user to go to the page containing a question they have not answered. The code that creates the LinkButton is called, as well as the AddHandler line (I ran a Debug and saw that it executes this code, and the links are displayed on the page afterwards). However, the...
0
7695
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...
0
7922
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. ...
0
8119
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...
0
6281
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...
1
5509
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...
0
3653
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...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
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...

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.