Solved

adding li to the ul from server side code

Posted on 2012-03-13
4
1,935 Views
Last Modified: 2012-04-11
I am trying to add li to ul from code behind.  Following is the html I have currently. I need to move this to vb.net

 <ul id="mycarousel" runat ="server"  class="jcarousel-skin-tango">       
        <li><a href = "/rebate/b0" ><img src="/Assets/Rebate/PaperClipsEtc100.jpg" style="background-color:#E7E7E9;padding:4px;border:1px solid #D6D7D9;" /></a></li>            
    </ul>      
I started of with this , but I dont see the image. Please help

     For countRebate As Integer = 0 To dtRebates.Rows.Count - 1
                Dim liCarousel As New HTMLGENriccontrol
                mycarousel.Controls.Add(liCarousel)

                Dim anchorCarousel As New HtmlAnchor
                anchorCarousel.Attributes.Add("href", "/rebate/b" & dtRebates.Rows(countRebate)("BrandID"))
                liCarousel.Controls.Add(anchorCarousel)

                Dim imgCarousel As New HtmlImage
                imgCarousel.Attributes.Add("src", "/Assets/images/products/mfglogos/3M_LOGO.jpg")
                anchorCarousel.Controls.Add(imgCarousel)
            Next
0
Comment
Question by:TrialUser
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 167 total points
ID: 37717397
Why add the src by adding to the Attributes collection? The HtmlImage class exposes the Src property which you can assign to:

anchorCarousel.Src = Server.MapPath("/Assets/images/products/mfglogos/3M_LOGO.jpg")

Open in new window


Side comment: Same as the above:  You shouldn't have to do the add attribute logic in order to set the anchor's HREF--there should be a property named Href which can use.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37717669
Have you seen the source that's rendered in browser? Can you show the relevant parts here?
0
 
LVL 11

Accepted Solution

by:
SAMIR BHOGAYTA earned 167 total points
ID: 37718289
Hello,

You have to put one literal control. Then after pass the ul and li into this literal like this.

literal.Text = "<ul><li></li></ul>"
0
 
LVL 9

Assisted Solution

by:sarabhai
sarabhai earned 166 total points
ID: 37718629
Dim ul As HtmlGenericControl = DirectCast(Page.FindControl("mycarousel"), HtmlGenericControl)
        Dim liToAdd As New HtmlGenericControl("li")
        liToAdd.InnerText = "Test"
        ul.Controls.Add(liToAdd)


try to add <image> inside the liToAdd control.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question