I am using aspx for my template in kentico with a CMSListMenu. The CMSListMenu is like this:
<cms:CMSListMenu CssClass="sm sm-blue" ID="main_menu" Path="/%"
runat="server" ClassNames="CMS.MenuItem" />
I want it to return something like this:
<ul class="sm sm-blue" ID="main_menu">
<li>Home</li>
<li>About Us</li>
<li>Products</li>
</ul>
How can I achieve this?
I tend to ignore the built-in web-parts in Kentico for lists. Rather using the <cms:CMSRepeater> and a transformation. The CMSRepeater is analogous to asp.net's <asp:Repeater> control, with the added access to the Kentico CMS tree structure.
So a deceleration of the CMSRepeater in code would look like:
<cms:CMSRepeater ClassNames="CMS.MenuItem" Path="/%" runat="server" >
<HeaderTemplate>
<ul class="sm sm-blue" id="main_menu">
</HeaderTemplate>
<ItemTemplate>
<li><%# Eval("DocumentName") %></li> <!-- Or whatever column you need to extract for the title-->
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</cms:CMSRepeater>
Alternately if you create the CMSRepeater web part in the CMS UI, you can set up the list header/footer directly in the dialog,
and point to a Transformation for a Document Type. The transformation is a separate file, and will contain the same scope as the content within <ItemTemplate> above.
Related
My project is built on the WebForm architecture. It uses role-based authorization of the standard ASP.NET Identity mechanism. I had a question how to dynamically create an html markup fragment, for example, if the role is an administrator, then the user sees the markup like this:
<li><a runat="server" href="~/WebLogisticTool>UploadContainerExcel</a></li>
<li><a runat="server" href="~/Home>Home</a></li>
<li><a runat="server" href="~/AdminPanel>AdminPanel</a></li>
if the role is a manager then:
<li><a runat="server" href="~/About>About</a></li>
<li><a runat="server" href="~/Home>Home</a></li>
Create table with userrights with menu options.
While login get data from this table for menu options and bind this options using element or using Repeater control
Case
I want an interface that lets users search through existing items and provide matches in three columns. but performance is quite essential. So let's say the datasource is a list of people from which I retrieve Name, PhoneNo and Email. I use Telerik's RadComboBox and it's built-in EnableLoadOnDemand (that reloads the list upon keypresses, pastes, etc.).
From a first test, I've seen performance hits appear somewhere around the 500 dataitems mark. To me, this is not unreasonable at all, as the pattern matching is done not only in all three columns, but also is of the type Contains (i.e. it matches anywhere in a string). By the way, when switching search mode to StartsWith, I don't see any significant performance increases.
RadComboBox
<telerik:RadComboBox runat="server" ID="RadComboBox1"
Height="290px" Width="700px" EmptyMessage="Enter your query" EnableVirtualScrolling="False"
MarkFirstMatch="true" Filter="StartsWith" EnableLoadOnDemand="true"
HighlightTemplatedItems="true" AutoPostBack="True" EnableTextSelection="true"
DataSourceID="SqlDataSource1">
<HeaderTemplate>
<ul>
<li class="col1">Name</li>
<li class="col2">Mobile</li>
<li class="col3">E-mail</li>
</ul>
</HeaderTemplate>
<ItemTemplate>
<ul>
<li class="col1">
<%# DataBinder.Eval(Container.DataItem, "ContactName")%></li>
<li class="col2">
<%# DataBinder.Eval(Container.DataItem, "Mobile")%></li>
<li class="col3">
<%# DataBinder.Eval(Container.DataItem, "Email")%></li>
</ul>
</ItemTemplate>
</telerik:RadComboBox>
Is it reasonable for me to expect to pull this off with, say, 3000 data rows? THat is, are there any ways to optimize my approach?
You can consider creating your own filtering (e.g., by storing the data set you get when the handler is first hit, so it takes less time to retrieve data later) and returning a minimal amount of data: http://demos.telerik.com/aspnet-ajax/combobox/examples/populatingwithdata/autocompletesql/defaultcs.aspx. You can also reduce the items per request.
I'm trying to add an empty asp:BulletedList to a page so I can run a jquery on it. But when I open the page the bulletlist doesn't show up.
Is there a trick to getting an empty asp:BulletedList to show up?
Empty BulletedList like this:
<asp:BulletedList ID="BulletedList1" runat="server">
</asp:BulletedList>
will not render into page HTML at all because it makes no sense much as <UL> element without <LI> elements.
But if you add at least one (even empty) list item:
<asp:BulletedList ID="BulletedList1" runat="server">
<asp:ListItem></asp:ListItem>
</asp:BulletedList>
It will render as
<ul id="BulletedList1">
<li></li>
</ul>
I'm trying to implement a search bar to filter dynamic content in jQuery mobile by first letter. I want to implement data-filter like this: http://jquerymobile.com/demos/1.0a4.1/docs/lists/docs-lists.html#../../docs/lists/lists-search-inset.html
Super easy to do. However, I have a minor problem throwing me off. All my content is dynamic. Each record being read is a new list. Because data-filters are used for lists, I have a search bar above each record. My .NET code for my output looks like this:
<asp:Repeater ID="Repeater27" runat="server" DataSourceID="SqlDataSource27">
<ItemTemplate>
<ul data-role="listview" data-inset="true" data-filter="true">
<li class="list-head"><strong><%# Eval("Name")%></strong></li>
<li class="list-body"><%# Eval("GrEmail")%></li>
<li class="list-body"><%# Eval("Telephone")%></li>
</ul>
</ItemTemplate>
</asp:Repeater>
Because I am using a Repeater to list my dynamic content, it too is repeating my filter. I have tried moving the filter outside of my repeated region, and this doesn't work. In addition, the filter has to be attached to the list it is reading to work anyway.
Is there a work around from using a repeater in .NET?
Or is there a workaround for filters?
Can data-filter work for collapsible-sets?
I'm open to any and all suggestions. I greatly appreciate any insight you may have to offer. This has got to be a common problem with implementing dynamic content on a site. I'm wondering how the jQuery mobile documentation did this??
Thoughts?
Only Li should be repeated !! :)
change it with
`
<ul data-role="listview" data-inset="true" data-filter="true">
<asp:Repeater ID="Repeater27" runat="server" DataSourceID="SqlDataSource27">
<ItemTemplate>
<li class="list-head"><strong><%# Eval("Name")%></strong></li>
<li class="list-body"><%# Eval("GrEmail")%></li>
<li class="list-body"><%# Eval("Telephone")%></li>
</ItemTemplate>
</asp:Repeater>
</ul>
`
The should be outside of the repeater. The remaining dynamic content should then be within only one set of tags.
I have the feeling that using Sitemap in ASP.NET is not conducive to CSS. Where do I format a menu to look like CSS can make it look. Where are mu ul and li's?
...Beginner, so forgive me if there right under my nose.
Why not just use a CSS menu with ul's and li's ? There is nothing in ASP.NET that says you have to use web controls, normal HTML works just as well (probably better).
Using a SiteMap is extremily useful when using it to show Menus and Breadcrums.
You can read some tutorials on how to accomplish this like this. If you want to generate pure UL / LI I suggest you read this post
There is always the ASP.NET Video tutorial on How Do I: Implement Site Navigation in ASP.NET?
Try, as well use the CSS Friendly Adapters (that's what they were build for) - there's a video tutorial as well.
Hope it helps
For complete control over a menu you could use a Repeater and bind it to your Web.SiteMap.
<asp:Repeater ID="MenuRepeater" DataSourceID="SiteMapDataSource1" runat="server">
<ItemTemplate>
<li>
<a href='<%#Eval("url")%>'><%#Eval("Title")%></a>
</li>
</ItemTemplate>
</asp:Repeater>
If you're looking to do CSS dropdown menus then simply add in a nested Repeater.
<asp:Repeater ID="MenuRepeater" DataSourceID="SiteMapDataSource1" runat="server" EnableViewState="false">
<ItemTemplate>
<li>
<a href='<%#Eval("url")%>'><%#Eval("Title")%></a>
<ul>
<asp:Repeater ID="DropDownRepeater" DataSource='<%#Container.DataItem.ChildNodes()%>' runat="server">
<ItemTemplate>
<li>
<a href='<%#Eval("url")%>'><%#Eval("Title")%></a>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
</li>
</ItemTemplate>
</asp:Repeater>
So you'll get the CSS menus you want and still be using your Web.SiteMap.
You can combine the SiteMapDataSource with a Repeater tu produce a standard <ul><li> menu list. You can even add your own attributes to the web.sitemap file, e.g. to specify an image for the menu item...
teknohippy's advice on using a repeater is great!
However, the line
<asp:Repeater ID="DropDownRepeater" DataSource='<%#Container.DataItem.ChildNodes()%>' runat="server">
is incorrect. It needs to be
<asp:Repeater ID="Repeater1" runat="server" DataSource='<%# ((SiteMapNode) Container.DataItem).ChildNodes %>'>
in order to work.
Details are available in this excellent tutorial:
http://msdn.microsoft.com/en-us/library/aa581781.aspx