Results 1 to 18 of 18

Thread: [RESOLVED] Linkbutton click event not firing

  1. #1

    Thread Starter
    Addicted Member Isorfir's Avatar
    Join Date
    Feb 2006
    Location
    In Debug Mode
    Posts
    133

    Resolved [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

  2. #2
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Linkbutton click event not firing

    can you post some code?
    * 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

  3. #3

    Thread Starter
    Addicted Member Isorfir's Avatar
    Join Date
    Feb 2006
    Location
    In Debug Mode
    Posts
    133

    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

  4. #4
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    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

  5. #5

    Thread Starter
    Addicted Member Isorfir's Avatar
    Join Date
    Feb 2006
    Location
    In Debug Mode
    Posts
    133

    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

  6. #6
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    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

  7. #7

    Thread Starter
    Addicted Member Isorfir's Avatar
    Join Date
    Feb 2006
    Location
    In Debug Mode
    Posts
    133

    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

  8. #8
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    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

  9. #9

    Thread Starter
    Addicted Member Isorfir's Avatar
    Join Date
    Feb 2006
    Location
    In Debug Mode
    Posts
    133

    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

  10. #10
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    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

  11. #11
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    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

  12. #12

    Thread Starter
    Addicted Member Isorfir's Avatar
    Join Date
    Feb 2006
    Location
    In Debug Mode
    Posts
    133

    Re: Linkbutton click event not firing

    There appears to nothing under the Forms collection.
    IDE: Visual Studio 2008/2010 - C# | VB.Net

  13. #13
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    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

  14. #14

    Thread Starter
    Addicted Member Isorfir's Avatar
    Join Date
    Feb 2006
    Location
    In Debug Mode
    Posts
    133

    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

  15. #15
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  16. #16
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    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

  17. #17

    Thread Starter
    Addicted Member Isorfir's Avatar
    Join Date
    Feb 2006
    Location
    In Debug Mode
    Posts
    133

    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

  18. #18
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] Linkbutton click event not firing

    Quote Originally Posted by Isorfir View Post
    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
  •  



Click Here to Expand Forum to Full Width