?
Solved

VB.Net Object write to HTML

Posted on 2008-10-20
6
Medium Priority
?
594 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
Industry Leaders: 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!

 

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 2000 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

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
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…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
Suggested Courses

765 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