|
-
Jan 18th, 2010, 02:09 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Linkbutton click event not firing
I've placed a link button control on my web form and added the click event to the code behind (automatically), but I've placed a break point and it never hits it. If I do the same thing with a button it works just fine.
I've searched for this problem and none of the results seem to answer why mine isn't working. Maybe I'm just missing something?
Thanks.
IDE: Visual Studio 2008/2010 - C# | VB.Net
-
Jan 18th, 2010, 03:22 PM
#2
Re: Linkbutton click event not firing
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Jan 18th, 2010, 03:27 PM
#3
Thread Starter
Addicted Member
Re: Linkbutton click event not firing
Code:
protected void LinkButton1_Click(object sender, EventArgs e)
{
txtOutput.Text = ckboxUserDevices.Items[0].Value;
}
That's really the only code that I'm using, which is autogenerated. I have a breakpoint set so it really doesn't matter what's between the brackets.
Is there maybe a property that I should set on the LinkButton?
IDE: Visual Studio 2008/2010 - C# | VB.Net
-
Jan 18th, 2010, 03:53 PM
#4
Re: Linkbutton click event not firing
Hi it should work just to confirm in your linkbutton markup code you the OnClick property set like so:
Code:
OnClick="LinkButton1_Click"
and you didn't set the EnableViewState property to "False" ?
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Jan 18th, 2010, 04:00 PM
#5
Thread Starter
Addicted Member
Re: Linkbutton click event not firing
I agree, it should work, which makes this frustrating. I even tried setting CausesValidation to false, but that didn't help. Here's what I have for the button:
Code:
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False"
EnableViewState="False" onclick="LinkButton1_Click">LinkButton</asp:LinkButton>
IDE: Visual Studio 2008/2010 - C# | VB.Net
-
Jan 18th, 2010, 04:02 PM
#6
Re: Linkbutton click event not firing
you set EnableViewState to false!!
this is the reason it doesn't work for you...
set it to True or handle the Request.Form
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Jan 18th, 2010, 04:06 PM
#7
Thread Starter
Addicted Member
Re: Linkbutton click event not firing
Sorry, I thought you had told me to set it to false, but now I see you were making sure I didn't. Originally it was the default:
Code:
<asp:LinkButton ID="LinkButton1" runat="server"
onclick="LinkButton1_Click">LinkButton</asp:LinkButton>
IDE: Visual Studio 2008/2010 - C# | VB.Net
-
Jan 18th, 2010, 04:12 PM
#8
Re: Linkbutton click event not firing
mmm That's wired..
i tested it on my machine and it's work fine, can you see this linkbutton Form collection in the page trace?
did you tried to delete this button/ drop new one and recompile your project?
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Jan 18th, 2010, 04:28 PM
#9
Thread Starter
Addicted Member
Re: Linkbutton click event not firing
I know, very weird.
can you see this linkbutton Form collection in the page trace?
Where do I find that exactly? (sorry)
I have tried deleting, add another, clean, rebuild. Nothing seems to help.
IDE: Visual Studio 2008/2010 - C# | VB.Net
-
Jan 18th, 2010, 04:34 PM
#10
Re: Linkbutton click event not firing
in your page directive add Trace="True"
then you'' be able to see the form collection
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Jan 18th, 2010, 04:38 PM
#11
Re: Linkbutton click event not firing
can you post more of the markup around the linkbutton?
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Jan 18th, 2010, 04:41 PM
#12
Thread Starter
Addicted Member
Re: Linkbutton click event not firing
There appears to nothing under the Forms collection.
IDE: Visual Studio 2008/2010 - C# | VB.Net
-
Jan 18th, 2010, 04:43 PM
#13
Re: Linkbutton click event not firing
is your html markup is big? can you post it here?
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Jan 18th, 2010, 05:01 PM
#14
Thread Starter
Addicted Member
Re: Linkbutton click event not firing
You saying if I could post my html made me go through it throughly (trying to comment out as much I could to cut down the size) and a came across something I did awhile ago. I was messing with accessing javascript and had this in there:
Code:
<form name="Form2" method="post" id="Form2" action="Default.aspx">
<input type="hidden" name="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" value="" />
<input type="hidden" id="__outputMessage" name="__outputMessage" value="" />
<input type="button" id="formSubmit" onclick="checkWPF();" value="Test" style="display:none;"/>
</form>
Long story short, it looks like having this second form made my LinkButtons misbehave. Luckily, I don't need that to work at the moment, though I may sometime in the future.
IDE: Visual Studio 2008/2010 - C# | VB.Net
-
Jan 18th, 2010, 05:07 PM
#15
Re: [RESOLVED] Linkbutton click event not firing
Hey,
When you first added the LinkButton to your page, how did you hook up the event handler? Did you double click the LinkButton?
Use this FAQ:
http://www.vbforums.com/showthread.php?t=595480
And check the properties window of the LinkButton and make sure the Click event is linked to the event handler.
Gary
-
Jan 18th, 2010, 05:07 PM
#16
Re: [RESOLVED] Linkbutton click event not firing
Heh :B
it had to be something like that..
well you live and learn 
Good luck!
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Jan 18th, 2010, 05:31 PM
#17
Thread Starter
Addicted Member
Re: [RESOLVED] Linkbutton click event not firing
Gary,
I did make sure the Click event was tied in, but thanks for that link, it will be a helpful reference in the future.
motil,
Thanks again for the patience.
IDE: Visual Studio 2008/2010 - C# | VB.Net
-
Jan 19th, 2010, 03:56 AM
#18
Re: [RESOLVED] Linkbutton click event not firing
 Originally Posted by Isorfir
I did make sure the Click event was tied in, but thanks for that link, it will be a helpful reference in the future.
That's why I wrote it
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|