Solved

VB.Net Object write to HTML

Posted on 2008-10-20
6
586 Views
Last Modified: 2012-08-13
Hi,

I need to take information from my obj and write it to html.

It's basically report information, so it needs to be all nice and formatted in a table as well.

Any help getting me started?

Thx
0
Comment
Question by:bdb12
6 Comments
 
LVL 8

Expert Comment

by:mkosbie
ID: 22759777
1) What about using Crystal Reports? (Comes with Visual Studio Professional editions). http://www.dotnetjunkies.ddj.com/Article/790775A0-C493-46D8-ABE0-40CA588D33D3.dcik .

2) Otherwise, you can use a FormView object connected to you're object through an ObjectDataSource and retrieve the data that way (http://www.asp.net/LEARN/data-access/tutorial-04-vb.aspx).

3) You could create a render method on the object and generate the HTML directly.  It's difficult to use this option because you cannot see the page until the code actually executes.  It's also difficult to maintain.
0
 
LVL 18

Expert Comment

by:jcoehoorn
ID: 22759852
If the object is marked as "Serializable" you can write it to Xml using a System.Xml.XmlSerializer object.  Then you can transform that Xml into HTML using an XSLT transform.
0
 
LVL 18

Expert Comment

by:jcoehoorn
ID: 22759858
Oh, and if this is just an ASP.Net page, you might look at a DetailsView control.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:bdb12
ID: 22759938
Im just after something simple.....

Say I have an array in the Object. I just want to write.....

<table>
<tr>
<td>ArrayVar[0]</td>
<td>ArrayVar[1]</td>
</tr>
<tr>
<td>ArrayVar[2]</td>
<td>ArrayVar[3]</td>
0
 
LVL 8

Accepted Solution

by:
mkosbie earned 500 total points
ID: 22760449
Use a render method.
Imports Microsoft.VisualBasic
 

Public Class Class1

    Private myArray As String()
 

    Public Function Render() As String

        Dim HTML As New StringBuilder("<table><tr>")
 

        Dim i As Integer

        For i = 0 To myArray.Length

            HTML.Append("<td>" & myArray(i) & "</td>")

            If IsEven(i) Then

                HTML.Append("</tr><tr>")

            End If

        Next
 

        HTML.Append("</tr></table>")

        Return HTML.ToString()

    End Function
 

    Private Function IsEven(ByVal num As Integer) As Boolean

        Dim bitCmp As Integer = (num And 1)

        If bitCmp = 1 Then Return False

        Return True

    End Function

End Class

Open in new window

0
 

Expert Comment

by:sobreiro01
ID: 22763509
you should inherits from a base class like compositecontrol or make use of one ready, as "label" or a "panel".

Override the RenderControl method to build the HTML you want. So you are free to do whatever you want.

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 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

23 Experts available now in Live!

Get 1:1 Help Now