Menu Control - Templates

Discussion in 'ASP .Net Web Controls' started by Jay, Jan 18, 2006.

  1. Jay

    Jay Guest

    When I setup a StaticItemTemplate using a HTML table, for example, how do I
    implement the ability to select. If I do something like the following I
    lose the ability to select.

    <table cellpadding=4 cellspacing=0 border=1>

    <tr>

    <td> <%# Eval("Text") %></td>

    <td>Next</td>

    </tr>

    </table>



    Thanks

    Jay
    Jay, Jan 18, 2006
    #1
    1. Advertising

  2. Hi Jay,

    Welcome.
    As for the MenuItem's staticItemTemplate problem, I've just performed some
    tests through the template html you provided and did encouter the problem.
    Actually when we use custom Static or Dynamic Item template, the asp.net
    Menucontrol will embeded them in its autogenerated <a href='xxx'> link
    element... So if you just put some simple element like "<div>....</div>"
    in the template, you'll find that the select postback still works well...
    For your scenario, you put an html <table> element, such the clientside
    click event maybe captured by the <table > element, but did not raise it
    further to the parent <a> link element , thus, cause the selected post back
    event not fire.... Currently I've tried use some simple client scripts to
    manually let the table raise the click event to its parent element and it
    works well. Here is the test code I used, you can have a test on yoru side
    to see whether it helps:

    =======================
    <asp:Menu ID="Menu1" runat="server" StaticDisplayLevels="2"
    OnMenuItemClick="Menu1_MenuItemClick">
    <StaticItemTemplate>
    <div style="background-color:Yellow">
    <table cellpadding="4" cellspacing="0" border="1"
    onclick="this.parentElement.click();">
    <tr>
    <td>
    <%# Eval("Text") %>
    </td>

    ...................

    =======================

    Hope helps. Thanks,

    Steven Cheng
    Microsoft Online Support

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



    --------------------
    | From: "Jay" <>
    | Subject: Menu Control - Templates
    | Date: Wed, 18 Jan 2006 10:56:25 -0500
    | Lines: 23
    | X-Priority: 3
    | X-MSMail-Priority: Normal
    | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
    | X-RFC2646: Format=Flowed; Original
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
    | Message-ID: <>
    | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
    | NNTP-Posting-Host: c-24-98-72-48.hsd1.ga.comcast.net 24.98.72.48
    | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
    | Xref: TK2MSFTNGXA02.phx.gbl
    microsoft.public.dotnet.framework.aspnet.webcontrols:32562
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
    |
    | When I setup a StaticItemTemplate using a HTML table, for example, how do
    I
    | implement the ability to select. If I do something like the following I
    | lose the ability to select.
    |
    | <table cellpadding=4 cellspacing=0 border=1>
    |
    | <tr>
    |
    | <td> <%# Eval("Text") %></td>
    |
    | <td>Next</td>
    |
    | </tr>
    |
    | </table>
    |
    |
    |
    | Thanks
    |
    | Jay
    |
    |
    |
    Steven Cheng[MSFT], Jan 19, 2006
    #2
    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. Fred
    Replies:
    1
    Views:
    582
    Neredbojias
    Sep 26, 2005
  2. John Harrison

    using templates in templates

    John Harrison, Jul 31, 2003, in forum: C++
    Replies:
    8
    Views:
    376
    Torsten Curdt
    Jul 31, 2003
  3. JKop
    Replies:
    3
    Views:
    454
  4. Tom McCallum

    Templates within templates

    Tom McCallum, Aug 4, 2004, in forum: C++
    Replies:
    2
    Views:
    357
    tom_usenet
    Aug 4, 2004
  5. recover
    Replies:
    2
    Views:
    789
    recover
    Jul 25, 2006
Loading...

Share This Page