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. Advertisements

  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. Advertisements

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. Bryan
    Replies:
    1
    Views:
    960
    Steven Cheng[MSFT]
    Mar 1, 2006
  2. JKop
    Replies:
    3
    Views:
    682
  3. Replies:
    0
    Views:
    1,795
  4. empire5
    Replies:
    1
    Views:
    720
    =?Utf-8?B?UmVuZ2E=?=
    Jan 11, 2007
  5. recover
    Replies:
    2
    Views:
    1,061
    recover
    Jul 25, 2006
  6. Mike Tavares

    Adding Access keys to menu items in the Menu control

    Mike Tavares, Dec 23, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    648
  7. Philip
    Replies:
    1
    Views:
    452
  8. Perry Loh
    Replies:
    0
    Views:
    446
    Perry Loh
    Mar 24, 2006
Loading...