Rendering An Unordered List Using C#?
Feb 26, 2010
I need to render a unordered list with the data obtained from database using asp.net/C#.My data looks something like this.
id Name Depth
1 ELECTRONICS 0
2 TELEVISIONS 1
3 Tube 2
4 LCD 2
5 Plasma 2
6 Portable electronics 1
7 MP3 Player 2
8 Flash 3
9 CD Players 2
10 2 Way Radio 2
using the above sample data I need to render an unordered list based on the depth, in the following format
[code]...
View 3 Replies
Similar Messages:
Mar 25, 2010
I have a master page which has an unordered list in this way:
[code]....
These links are directed to my content pages. I am able to highligt the selected list item on hover and on active.
But I do not understand how I can highlight the selected list item as long as the user is on that specific page/link (current list item). I know that we can specify a seperate body tag and id for each of the content pages and then use CSS to highlight the current list item, but all this code rests already inside a body tag in the master page.
View 7 Replies
Jun 8, 2010
I am trying to implement an html definition list in which each <dt> is the <header> in the accordion, and <content> is the <dd>. No matter how I write this out I can't get it to be valid markup because of the position of the <div>s inside the definition list where divs aren't allowed.
I also tried using a unordered list but had the same validation issues. I would really like to use the accordian, but not if I have to sacrifice valid semantic markup on my page.
View 2 Replies
Jun 21, 2010
Is it possible to iterate through an unordered list like the following in codebehind?
[Code]....
I was hoping to iterate through all the li elements of the ul checking whether NavigateUrl is equal to the current url. If it is, I was going to add a CssClass to give it a different appearance.
I think I know how to compare it to the page's url and to how to add the css class. I'm just not quite sure how you iterate through li items using a HTML Generic control.
View 5 Replies
Jun 24, 2010
i am working on a dynamic tree menu with nested <ul><li>-Lists.
when building the nested list every <li> element should contain a <div> with a small icon and a css-style behind.
here is my code:
[Code]....
this way the result in the browser shows the name of every "aNavItem" but there are no icons. if i put the line to set the inner text of the div BEFORE adding the "imgMove" to it both things are shown - the name of the element and on the right the icon
the problem is that i want the icon to be on the left and then the text, but there is no icon at all with the code above (it looks like the setting of the inner text overwrites the already added image-control in the div-tag)
View 2 Replies
Jul 9, 2010
Is it possible to render a TreeViewControl as an unordered list instead of a table?
View 2 Replies
Jul 18, 2010
I've got this web control that I've been dynamically adding controls to but now the requirement is to add an ordered list around the controls.
To render the controls I add the controls to ControlsCollection
[code]...
How do I position the controls in the list items?
Do I need to approach the problem differently?
View 2 Replies
Jan 7, 2011
I have web form and on it I have a DataList that is grabbing some Data from a Database and displaying them as a list.However when I look at the HTML Source Code produced, it's all Tables ! <td> and <tr> !!
How can I stop this ? I want my DataList to display the data like so:
[Code]....
View 8 Replies
Mar 19, 2011
i have an unordered list <ul><li><ul><li>
I had made a table to fill the unordered list but how to fetch that data into li and ul the table consists of home, organisation (with children as policy, employeesdetails), and so on.. How do i fill these ul and li's and children of li's with data from sqlserver2005 table?
I'm not supposed to use any asp.net built in controls like asp.net menu
[code]...
View 1 Replies
Mar 16, 2010
I've data which looks something like this.
[code]....
To convert the above data into unordered list based on depth, I'm using the following code
[code]...
But the resulting unordered list doesnt seem to be forming properly(using which i am constructing a tree).For example "Site " with id '180' is supposed to appear as a direct child of "Televisions" with id '1',is appearing as a direct child of 'Flash' with id '191' using my code.so in addition to considering depth,I've decided to consider itemid as well in order to get the treeview properly.Those rows of the table with itemId not equal to null are not supposed to have a child node(i.e.,they are the leaf nodes in the tree) and all the other nodes can have child nodes.
Update:
The 'itemid' column refers to the id of an item which is present in another table.This column just in identifying if an item has any sub items(i.e., 'name' in my data in this case has any other unordered lists under it).
View 1 Replies
May 7, 2015
HtmlGenericControl li = new HtmlGenericControl("li");
tabs.Controls.Add(li);
li.InnerText = "new menu";
HtmlGenericControl anchor = new HtmlGenericControl("a");
anchor.Attributes.Add("href", "page.htm");
anchor.InnerText = "TabX";
li.Controls.Add(anchor);
I am using above code on my master.cs file to add new line like
<li id="one"><a href="page.htm"></a></li>on my .master filebut it not working...what i missingcode not showing any error..
View 1 Replies
Oct 2, 2010
[Code]....
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error:
[Code]....
View 4 Replies
Mar 1, 2011
I've migrated a test site to asp.net 4.0 to take advantage of the list renderingmode for a menu. Having the UL and LI should be easier than the table rendering.I'm making progress, (still have work to do, just ignore the odd border) however one issue continues to plague the testing. IN IE 6,7,8, as the page is rendering, it appears the menu is flickering and trying to render as a vertical menu instead of the correct
orientation which is horizontal. In Moz, Chrome, Sarafi, Opera, I don't get this behavior.
The menu is styled with CSS however I'm not opposed to adding some corrective code directly to the masterpage that holds the menu. I'd apprecate a suggestion as to how to solve this because as it is, it is not usable.Here is the link to the test site.
http://testbeachcrab.net.serv7.temphostspace.com/default.aspx
View 5 Replies
Jul 16, 2010
I have the following code in my post action method for Edit.
JobCardService.Update(viewData.JobCard);
var js = new JavaScriptSerializer();
ViewData["Notifications"] = js.Serialize(new {NoteificationType = "Success", Message = "The installtion was successfully updated"});
return RedirectToAction("Index");
However, on the client, ViewData is null/empty, i.e. this client code
var notifications = eval("<%= ViewData["Notifications"]%>");
renders as
var notifications = eval("");
I'm sure I'm doing something small wrong.
View 1 Replies
Apr 13, 2010
Im using the ASP.NET Xml control and want to pass it a url to a rss feed and a stylesheet - so that i can style the rss myself on my website. When applying the full web path to the xml control [URL] i get an exception telling me that the document source is not a valid virtual path. What am i doing wrong? I would hate to download the file before showing it...
View 1 Replies
Jan 18, 2010
I am learning MVC using the v2 release with Entity Framework v4. Let's say I have 3 objects Game, Points and Players. They are related in the following manner:Game has points and the Points can have a player associated with them ( 1 Game to many Points and a Point object can have one Player).
I am attempting to use the EditTemplates feature in MVC2 to render my views. In my Game Edit view I want to have the basic Game object information editable, and also the related Points objects. Currently I am utilizing "`<%= Html.EditorForModel() %>`"(Which seems pretty slow) to render the Edit View and then I have a specific Game and Point EditTemplates.
The data renders correctly and is editable for both the Game and Point information. When I go to perform the update and submit the form I receive the "Game" object in my Update ActionResult. The basic properties are populated for the Game object but any deep properties such as Points are not; they appear as null. If I look at the Request.Form variables in debug I can see the Points fields are being passed to the server but do not place themselves back into the Game object.
In my Game EditTemplate I am using the following to render the Points objects:
<%= Html.EditorFor(c => c.Points) %>
My Points EditTemplate looks like: [code]...
why this is rendering as "Points.Points[index] instead of Points[index]? I tried messing with the parameters in the EditFor:
<%= Html.EditorFor(c => c.Points,null,"Points") %>
but then the inputs render as Points.Points[index]
View 1 Replies
Jul 17, 2010
I have the following line of code in an MVC2 project but I cant get it to render the HTML from the database, all I that is displayed is the HTML.
<%: (Model.Blog.BlogDetail)%>
View 2 Replies
Aug 13, 2010
I cannot seem to get over this problem. Im sure it is just a simple newbie question but I just cannot find the right answer on my own.
Im using MVC 2 and ASP. NET 4.0 to biuld simple CMS. Im storing encoded HTML in XML file which then i am passing to front page controller for display.
I understand that before inserting HTML from XML into the page, it should be decoded using HttpUtility.Decode() function.
[Code]....
I expected that this sould result in inserting decoded HTML into my index.aspx page. Then browser could render my decoded content for example in bold face.
What happens is quite awkward. In page source I have encoded HTML but it renders HTML with tags. For example I see "<strong> Lorem ipsum </stong>", instead of Lorem Ipsum.
View 5 Replies
Mar 10, 2011
I find it hard when using asp.net controls, to make proper css files because I don't know what the html output for the different controls end up as. For example, if I want to add a div tag using a asp.net control, it's not easy to know what kind of control I can use.
Are there any documentation that shows for each asp.net control, what the rendered html for that control will be? I understand that some controls will probably change it's output due to how it's configured, but most controls will at least follow a pattern here.
The best would of course be a service on the web where you can put in the asp.net control definition and get the rendered html out. Currently I have to put a control into my webform, run it and check the source in the browser, and if it's not the correct html tag, try another control and repeat. That get's tedious quite fast.
View 2 Replies
Sep 12, 2010
I want to change some elements text when page is leaving the server (page_render, endRequest etc.).
How can i get access to the page and how can i find the elements to change their values, texts?
View 3 Replies
May 24, 2010
In my webpage i use the following in order filling the listview control
<asp:ListView ID="ListView1" runat="server">
<layouttemplate>
<asp:PlaceHolder id="itemPlaceholder" runat="server" /></layouttemplate>
<ItemTemplate>
<tr>
<td><asp:Label ID="Label1" runat="server" Text = '<%# DataBinder.Eval(Container.DataItem, "Ans1") %>' Visible = '<%# DataBinder.Eval(Container.DataItem, "Ans1Visible") %>'></asp:Label>
<br />
<asp:Label ID="Label2" runat="server" Text = '<%# DataBinder.Eval(Container.DataItem, "Ans2") %>' Visible = '<%# DataBinder.Eval(Container.DataItem, "Ans2Visible") %>'></asp:Label>
<br />
<asp:Label ID="Label3" runat="server" Text = '<%# DataBinder.Eval(Container.DataItem, "Ans3") %>' Visible = '<%# DataBinder.Eval(Container.DataItem, "Ans3Visible") %>'></asp:Label>
<br />
<asp:Label ID="Label4" runat="server" Text = '<%# DataBinder.Eval(Container.DataItem, "Ans4") %>' Visible = '<%# DataBinder.Eval(Container.DataItem, "Ans4Visible") %>'></asp:Label>
<br />
<asp:Label ID="Label5" runat="server" Text = '<%# DataBinder.Eval(Container.DataItem, "Ans5") %>' Visible = '<%# DataBinder.Eval(Container.DataItem, "Ans5Visible") %>'></asp:Label>
<br />
<asp:Label ID="Label6" runat="server" Text = '<%# DataBinder.Eval(Container.DataItem, "Ans6") %>' Visible = '<%# DataBinder.Eval(Container.DataItem, "Ans6Visible") %>'></asp:Label>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
Now i would like to add numbers to the labels before they are rendered. For example currently the data displayed are like
Tennis
Football
Basketball
Nfl
Nba
Polo
and the output i would like to have is
1. Tennis
2. Football
3. Basketball
4. Nfl
5. Nba
6. Polo
Could i use ListView1_ItemCreated or the ListView1_ItemDataBound event to achieve this? If that is true, could you point me a place to start? the list view is filled with
Dt = GetDataTable("SELECT Ans1, Ans2,Ans3,Ans4,Ans5,Ans6, Ans1Visible,Ans2Visible,Ans3Visible,Ans4Visible,Ans5Visible,Ans6Visible, From myTable WHERE CatID ='" & cat & "'")
ListView1.DataSource = Dt
ListView1.DataBind()
View 4 Replies
Jan 20, 2010
I was wondering if it's possible to render an Html Helper in a View inside a codeblock. So instead of:
[code]....
And have this render. Of course as it is, it wont render, so is there a way to programically decide if a textbox can be added without having to have a million delimiters in the page to accomplish this?
View 2 Replies
Jan 19, 2010
Why is the following asp.net code not including styling information when being rendered to HTML?
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333"
GridLines="None">
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
Here is the HTML that is rendered:
<div class="AspNet-GridView" id="GridView1">
<table cellpadding="0" cellspacing="0" summary="">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Age</th>
<th scope="col">Sex</th>
</tr>
</thead>
<tbody>
<tr>
<td>Ronnie</td>
<td>25</td>
<td>M</td>
</tr>
<tr class="AspNet-GridView-Alternate">
<td>Tina</td>
<td>25</td>
<td>F</td>
</tr>
<tr>
<td>Lukus</td>
<td>4</td>
<td>M</td>
</tr>
</tbody>
</table>
</div>
There are no themes defined for this site. Any ideas what is going on? EDIT I created a new web site in VWD Express and copy and pasted my gridview code, which resulting in the following HTML being rendered:
<div>
<table cellspacing="0" cellpadding="4" border="0" id="GridView1" style="color:#333333;border-collapse:collapse;">
<tr style="color:White;background-color:#990000;font-weight:bold;">
<th scope="col">Name</th><th scope="col">Age</th><th scope="col">Sex</th>
</tr><tr style="color:#333333;background-color:#FFFBD6;">
<td>Ronnie</td><td>25</td><td>M</td>
</tr><tr style="color:#333333;background-color:White;">
<td>Tina</td><td>25</td><td>F</td>
</tr><tr style="color:#333333;background-color:#FFFBD6;">
<td>Lukus</td><td>4</td><td>M</td>
</tr>
</table>
</div>
Something is keeping styling information from being included in my original project.
View 2 Replies
Jan 13, 2011
I have a control used in our CMS and we don't have the source code for it, what I would like to do is change the rendered output of this control.
Now, I could have a check in my base Page class that checks if the control is being used on the page and then change the html that needs to be altered, but that seems a bit excessive for just 1 usage.
So is there any other way of changing the behaviour of the control without the source code? I'm thinking not other than the way described above.
View 1 Replies
Nov 8, 2010
I've implemented reCAPTCHA following the instructions on this site:[URL]However I am unable to get it to render on my lightbox. It renders as below when i check with firebug.
<noscript> <iframe src="http://www.google.com/recaptcha/api/noscript?k=6Lctg74SAAAAADV4UAfyRdEUdZi_FGc4PCqA7LEn" width="500" height="300" frameborder="0"> </iframe><br /><textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea><input name="recaptcha_response_field" value="manual_challenge" type="hidden" /> </noscript>
Note that when i look in firebug the < and > display as the text "& lt;" and "& gt;" (without the space)
Let me know if there's any additional information required to help with this problem.
View 1 Replies