Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

adding li to the ul from server side code

Posted on 2012-03-13
4
Medium Priority
?
2,040 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

Technology Partners: 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

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.…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

650 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