?
Solved

adding li to the ul from server side code

Posted on 2012-03-13
4
Medium Priority
?
1,980 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 668 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 668 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 664 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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month11 days, 3 hours left to enroll

770 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