V
Vassili King
Hi:
I was wondering if anybody had a similar problem and could help me out
with a situation I ran into. I would really appreciate any advice.
I've created an .aspx page for my Web Application in Visual Studio
2005. I'm using .NET version 2.0. The situation narrows down to the
following:
-- I have a Private Sub FillTable(ByVal parameter As String) that
programmatically generates as many <tr>...</tr> (TableRows) as there
are records in my database and adds them to a placeholder
(placeholder.controls.add(TableRow)).
-- Inside of the FilLTable subroutine amoung all other stuff I
generate
LinkButtons (one per record) like so:
Dim btnMyLinkButton As LinkButton
btnMyLinkButton = New LinkButton
btnMyLinkButton.Text = [getting a value from my
database]
btnMyLinkButton.ID = [first part of the ID] & "!"
& [second part of the ID] 'this is to be used
later
AddHandler btnMyLinkButton.Click, AddressOf
btnMyLinkButton_Click
...
-- Somewhere below the FillTable subroutine I have another sub:
Private Sub btnMyLinkButton_Click(ByVal s As Object, ByVal e
As System.EventArgs)
Dim B As LinkButton = DirectCast(s, LinkButton)
Dim ItemInfo() As String = B.ID.Split("!"c)
Dim OrderNumber As Int32 = Convert.ToInt32(ItemInfo(0))
Dim LineNumber As Int32 = Convert.ToInt32(ItemInfo(1))
Me.ViewState("PartNumber") = Nothing
AddPart(LineNumber, OrderNumber)
txtPartLookupControl.Text = String.Empty
End Sub
-- When I'm running my project, the link buttons are created normally,
but the onclick event does not catch btnMyLinkButton_Click, but is a
regular PostBack. That is, when a link button is clicked, the page
refreshes whithout even running btnMyLinkButton_Click sub. It looks
like AddHandler...AddressOf... is trying to get the sub, but doesn't
find it (probably because the sub isn't built yet or something like
that). I've tried to place btnMyLinkButton_Click() sub above
FillTable(), but that was silly anyway and sure didn't help.
Any suggestion would be highly appreciated.
Thank you very much for your time!
I was wondering if anybody had a similar problem and could help me out
with a situation I ran into. I would really appreciate any advice.
I've created an .aspx page for my Web Application in Visual Studio
2005. I'm using .NET version 2.0. The situation narrows down to the
following:
-- I have a Private Sub FillTable(ByVal parameter As String) that
programmatically generates as many <tr>...</tr> (TableRows) as there
are records in my database and adds them to a placeholder
(placeholder.controls.add(TableRow)).
-- Inside of the FilLTable subroutine amoung all other stuff I
generate
LinkButtons (one per record) like so:
Dim btnMyLinkButton As LinkButton
btnMyLinkButton = New LinkButton
btnMyLinkButton.Text = [getting a value from my
database]
btnMyLinkButton.ID = [first part of the ID] & "!"
& [second part of the ID] 'this is to be used
later
AddHandler btnMyLinkButton.Click, AddressOf
btnMyLinkButton_Click
...
-- Somewhere below the FillTable subroutine I have another sub:
Private Sub btnMyLinkButton_Click(ByVal s As Object, ByVal e
As System.EventArgs)
Dim B As LinkButton = DirectCast(s, LinkButton)
Dim ItemInfo() As String = B.ID.Split("!"c)
Dim OrderNumber As Int32 = Convert.ToInt32(ItemInfo(0))
Dim LineNumber As Int32 = Convert.ToInt32(ItemInfo(1))
Me.ViewState("PartNumber") = Nothing
AddPart(LineNumber, OrderNumber)
txtPartLookupControl.Text = String.Empty
End Sub
-- When I'm running my project, the link buttons are created normally,
but the onclick event does not catch btnMyLinkButton_Click, but is a
regular PostBack. That is, when a link button is clicked, the page
refreshes whithout even running btnMyLinkButton_Click sub. It looks
like AddHandler...AddressOf... is trying to get the sub, but doesn't
find it (probably because the sub isn't built yet or something like
that). I've tried to place btnMyLinkButton_Click() sub above
FillTable(), but that was silly anyway and sure didn't help.
Any suggestion would be highly appreciated.
Thank you very much for your time!