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
Solved

VB.Net Object write to HTML

Posted on 2008-10-20
6
590 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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

829 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