A
AndrewR
Hey all,
Have a strange one here I don't understand....
I have a DataList control in an .aspx page. Inside the DataList's
<ItemTemplate> is a single LinkButton control. On the initial page load-up
I bind the DataList, and set the LinkButton's text and CommandArgument
values to the two items in the result set using the <%# ... %> tags. The
LinkButton's OnClick handler is set to a sub call ShowScores. When the page
is run, I get on screen a nice list of links, and clicking any of them runs
the back side code ShowScores, which was my goal. No problem....but I can't
leave well enough alone.....
I thought that if I could disable the link that was just clicked, it would
make for a better interface...no double clicking the same link, visual cue
as to what was clicked, etc. The sub ShowScores has a signature as follows:
Protected Sub ShowScores(ByVal sender As System.Object, ByVal e As
System.EventArgs)
To disable the LinkButton control that was clicked, I simply added this in
the sub block:
Dim LButton As LinkButton = DirectCast(sender, LinkButton)
LButton.Enabled = False
Which worked, but when a second link was clicked, the first one was still
disabled. Ok, I thought about it, and came up with the following idea
(replacing the above lines):
Dim LButton As LinkButton
' Re-enable the game button last clicked, if applicable
If Not IsNothing(Session("LastButton")) Then
LButton = DirectCast(Session("LastButton"), LinkButton)
LButton.Enabled = True
End If
' Disable the game button just clicked
LButton = DirectCast(sender, LinkButton)
LButton.Enabled = False
' Save this button to session variable
Session("LastButton") = LButton
This however does not work (sort of). The one just clicked is disabled just
fine, but the previous button remains disabled as well. I set a breakpoint
on the 'LButton = Session("LastButton")' line and ran the project. On the
second time around the debugger kicks in. In the Command window I
type"?LButton" I get all the info of the previous button, and the Enabled is
False...which I would figure to be the case. I step a couple lines and get
out of the IF block and type the same line in the Command window again, and
again get the info of the previous button, but now it states the Enable
property is True. I hit F5 and am presented with my quandary....
The previous button is still disabled - despite the fact that I set it True
and the query in the Command window showed it to be set True.
Why is it I can recall the previous button from the Session variable, but it
will not re-enable it? It disabled it just fine. Help?
-- Andrew
Have a strange one here I don't understand....
I have a DataList control in an .aspx page. Inside the DataList's
<ItemTemplate> is a single LinkButton control. On the initial page load-up
I bind the DataList, and set the LinkButton's text and CommandArgument
values to the two items in the result set using the <%# ... %> tags. The
LinkButton's OnClick handler is set to a sub call ShowScores. When the page
is run, I get on screen a nice list of links, and clicking any of them runs
the back side code ShowScores, which was my goal. No problem....but I can't
leave well enough alone.....
I thought that if I could disable the link that was just clicked, it would
make for a better interface...no double clicking the same link, visual cue
as to what was clicked, etc. The sub ShowScores has a signature as follows:
Protected Sub ShowScores(ByVal sender As System.Object, ByVal e As
System.EventArgs)
To disable the LinkButton control that was clicked, I simply added this in
the sub block:
Dim LButton As LinkButton = DirectCast(sender, LinkButton)
LButton.Enabled = False
Which worked, but when a second link was clicked, the first one was still
disabled. Ok, I thought about it, and came up with the following idea
(replacing the above lines):
Dim LButton As LinkButton
' Re-enable the game button last clicked, if applicable
If Not IsNothing(Session("LastButton")) Then
LButton = DirectCast(Session("LastButton"), LinkButton)
LButton.Enabled = True
End If
' Disable the game button just clicked
LButton = DirectCast(sender, LinkButton)
LButton.Enabled = False
' Save this button to session variable
Session("LastButton") = LButton
This however does not work (sort of). The one just clicked is disabled just
fine, but the previous button remains disabled as well. I set a breakpoint
on the 'LButton = Session("LastButton")' line and ran the project. On the
second time around the debugger kicks in. In the Command window I
type"?LButton" I get all the info of the previous button, and the Enabled is
False...which I would figure to be the case. I step a couple lines and get
out of the IF block and type the same line in the Command window again, and
again get the info of the previous button, but now it states the Enable
property is True. I hit F5 and am presented with my quandary....
The previous button is still disabled - despite the fact that I set it True
and the query in the Command window showed it to be set True.
Why is it I can recall the previous button from the Session variable, but it
will not re-enable it? It disabled it just fine. Help?
-- Andrew