Results 1 to 5 of 5

Thread: label and onclick

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049

    Question label and onclick

    I wish to fire an onclick event when I click a label. But it fails. It's fine if I use a button. I am rewriting my javascript menus to .net code. Or does any have a better solution? I wish to activate a .net sub when I click a JS-menu.
    Code:
    <%@ Page Language="VB" %>
    <script runat="server">
    
        Sub panelhp(sender As Object, E As EventArgs)
            lblHp.text = "Test"
        
        end sub
    
    </script>
    <html>
    <head>
    </head>
    <body>
        <form runat="server">
            <asp:label id="Label1" onclick="panelhp" runat="server" text="Test"></asp:label>
            <asp:label id="lblHp" runat="server" text="Help"></asp:label>
        </form>
    </body>
    </html>

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    I am not that good with ASP.Net yet, but I think in VB.Net code you need to put a handles statement at the end of the sub:
    VB Code:
    1. Sub panelhp(sender As Object, E As EventArgs) Handles lblHp.Click 'or something like that....
    2.         lblHp.text = "Test"
    3.    
    4.     end sub

  3. #3
    Member Ooogaleee's Avatar
    Join Date
    Nov 2002
    Location
    Jacksonville, FL
    Posts
    52
    I don't think ASP labels have click events associated with them. You'll have to use a button, hyperlink, or something similar available for web forms...

    Ooogs

  4. #4
    New Member
    Join Date
    Apr 2001
    Location
    Ghent, Belgium
    Posts
    5
    hpl, you can not assign any action on a label control...

    greetz,

    Tim

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049
    OK, so I have to use a button and the hide the borderwidths? I have also tried to use this
    <asp:hyperlink ..../>. Can anyone give an example with onclick used with a hyperlink? I can't make it work, perhaps I use some events, which are not allowed.

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