ASP:HyperLink control and client-side scripting

Discussion in 'ASP .Net' started by Brian W, Mar 1, 2004.

  1. Brian W

    Brian W Guest

    Hi All,

    I know this is a dumb question, but I'll ask it anyway...

    How do you do client-side scripting with an ASP control?

    For example I have:

    <asp:hyperlink id="Hyperlink1" runat="server" NavigateUrl="~/"
    onclick="return false;">Home</asp:hyperlink>

    When I run this it works as expected, except the IDE sees it as and error.

    I know I can add the attribute in the codebehind, but is this possible in
    the HTML designer side?

    TIA
    Brian W
     
    Brian W, Mar 1, 2004
    #1
    1. Advertising

  2. Brian W

    bruce barker Guest

    not with the webcontrol controls, as asp.net assumes these are postback
    events

    -- bruce (sqlwork.com)

    "Brian W" <brianw@gold_death_2_spam_rush.com> wrote in message
    news:uT7wcz9$...
    > Hi All,
    >
    > I know this is a dumb question, but I'll ask it anyway...
    >
    > How do you do client-side scripting with an ASP control?
    >
    > For example I have:
    >
    > <asp:hyperlink id="Hyperlink1" runat="server" NavigateUrl="~/"
    > onclick="return false;">Home</asp:hyperlink>
    >
    > When I run this it works as expected, except the IDE sees it as and error.
    >
    > I know I can add the attribute in the codebehind, but is this possible in
    > the HTML designer side?
    >
    > TIA
    > Brian W
    >
    >
     
    bruce barker, Mar 1, 2004
    #2
    1. Advertising

  3. Hi Brain,


    Thanks for posting in the community!
    As for your question that "whether possible to add client side attributes
    in the ASP.NET server control's html source(aspx page)", I agree with bruce
    that we can only specify the Server control's specified attributes in its
    tag such as
    <asp:Button...> <asp:Label ...> ..
    In fact, when the asp.net runtime parsing the aspx page, it'll parse the
    asp.net server controls( not html server controls) according to its class
    in framework, and these classes has their buildin attributes which are
    quite different from html element's attributes( only for serverside code's
    controling). The runtime construct a server control's instance via the
    attribuets and finally render it out to client via some certain mapping
    (from these attributes to the proper html element attributes). So we can't
    add clientside used attributes in ASP.NET server control's source template
    in aspx page(html view). One way to do this is via their' "Attributes"
    collection in code behind as you've mentioned. If you do want to add
    clientside attributes in aspx file(html view), I think you can try using
    the HtmlServerControls instead, because they're directly mapping to html
    element. Do you think so?

    In addition, here are some tech ariticles on the ASP.NET servercontrols and
    html server controls:

    #ASP.NET Server Controls Recommendations
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
    vbconchoosingwebformscontrols.asp

    #ASP.NET Server Controls and Browser Capabilities
    http://msdn.microsoft.com/library/en-us/vbcon/html/vbconWebFormsControlsBrow
    serCapabilities.asp?frame=true

    #HTML Server Controls
    http://msdn.microsoft.com/library/en-us/cpgenref/html/cpconASPSyntaxForHTMLC
    ontrols.asp?frame=true

    #The Forgotten Controls: HTML Server Controls
    http://msdn.microsoft.com/library/en-us/dnaspp/html/ASPNet-ForgottenControls
    .asp?frame=true

    Hope these also helpful.


    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    Get Preview at ASP.NET whidbey
    http://msdn.microsoft.com/asp.net/whidbey/default.aspx
     
    Steven Cheng[MSFT], Mar 2, 2004
    #3
  4. Hi Brain,

    Have you had a chance to check out my suggestions in the last reply or have
    you got any further ideas on this issue? If you have any further questions,
    please feel free to post here.


    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    Get Preview at ASP.NET whidbey
    http://msdn.microsoft.com/asp.net/whidbey/default.aspx
     
    Steven Cheng[MSFT], Mar 4, 2004
    #4
  5. Brian W

    Brian W Guest

    I'm good, Thanks!

    BrianW



    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi Brain,
    >
    > Have you had a chance to check out my suggestions in the last reply or

    have
    > you got any further ideas on this issue? If you have any further

    questions,
    > please feel free to post here.
    >
    >
    > Regards,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    > Get Preview at ASP.NET whidbey
    > http://msdn.microsoft.com/asp.net/whidbey/default.aspx
    >
     
    Brian W, Mar 4, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mantorok
    Replies:
    9
    Views:
    444
    Eliyahu Goldin
    Jul 7, 2005
  2. Boss302
    Replies:
    0
    Views:
    1,103
    Boss302
    Nov 21, 2006
  3. Tom

    Calendar Control With Client-Side Scripting.

    Tom, Dec 2, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    315
    Ken Cox [Microsoft MVP]
    Dec 3, 2003
  4. Jim Ciotuszynski

    Client Side scripting user control

    Jim Ciotuszynski, Aug 4, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    117
    Jim Ciotuszynski
    Aug 4, 2004
  5. Kathryn
    Replies:
    9
    Views:
    222
    William Morris
    Oct 17, 2003
Loading...

Share This Page