Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8693317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:31:21+00:00 2026-06-13T00:31:21+00:00

I am trying to generate some HTML code from a VB.NET Web Method and

  • 0

I am trying to generate some HTML code from a VB.NET Web Method and return it as text.

Here’s an example markup:

<ul>
    <li>234: this is an item</li>
    <li>456: another item</li>
</ul>

I have some VB thus:

Dim rList As New HtmlGenericControl("UL") ' << create an HTML list container

    Try ' looping through a dictionary of item data
         For j = 0 To UBound(d("itemNo")) ' loiop through all individual item data
             Dim Item = d("itemNo")(j)
             Dim itemName =  d("itemName")(j)
             Dim liItem As New HtmlGenericControl("li") ' << creates an HTML list item
             liItem.InnerHtml += itemNo & ":" & itemName 
             rList.InnerHtml += liItem 
         Next
     Catch ex as Exception
         ' fail case
     End Try

Now, this will generate all the HTML tags and content perfectly well. If I were writing this out to a page, I could do that quite simply.

BUT… I don’t want to do that, I want to somehow return the actual HTML markup created by the above code as a text string, ie, I want return rList.toString() to return the markup, but instead it just returns the object type as a string.

I could do this without bothering with the HtmlGenericControl class at all and simply generate a whole load of strings with the opening and closing HTML tags, but the rest of this code is quite complex and there’s plenty of room for error… if I could achieve what I am looking for above it’d be much simpler to code!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:31:22+00:00Added an answer on June 13, 2026 at 12:31 am

    In order to do this the code should be as follows

    Dim rList As New HtmlGenericControl("UL") 
    
    Try 
         // Existing stuff
        Dim stringwriter As New System.IO.StringWriter()
        Dim writer As New HtmlTextWriter(stringwriter)
        rList.RenderControl(writer)
        Return stringwriter.ToString()
    
     Catch ex as Exception
         ' fail case
     End Try
    

    Good Luck !!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to generate some html programmatically in my code behind for a user
I am trying to write some code that will generate accurate .proto files from
I am trying to generate some code using Acceleo. I am constructing my model
I am trying to generate some code using CodeDom. I wanted to know if
I got some code from java httpurlconnection cutting off html and I am pretty
I'm trying to generate email from my code that will read correctly for people
I'm trying to retrive some data from a web site . I wrote a
I'm trying to port some code from Play Framework Java to Play Framework Scala
I am trying to retrieve some HTML files from Amazon s3 using AWS SDK
I'm trying to style some HTML, generated from Google Calendar , it's something I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.