Menu Control - Templates

J

Jay

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
 
S

Steven Cheng[MSFT]

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" <[email protected]>
| 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: <[email protected]>
| 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
|
|
|
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top