Solved

VB.Net Object write to HTML

Posted on 2008-10-20
6
592 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
[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
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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

732 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