Solved

adding li to the ul from server side code

Posted on 2012-03-13
4
1,799 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
4 Comments
 
LVL 74

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 167 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now