Solved

VB.Net Object write to HTML

Posted on 2008-10-20
6
585 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
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…

760 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

21 Experts available now in Live!

Get 1:1 Help Now