473,386 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Generating HTML in a web service

Perhaps I have missed something but what I would like to do is have a more
"controlled" method of generating HTML from a web service.

I can create items using HtmlTable, HtmlTableRow, and HtmlTableCell but is
there a quick method once the table has been built to get the HTML, put it
in a string for return the browser call for the web service?

I notice that HtmlTable does not support InnerHtml so that is not doable.

Ideas??

Thanks
Lloyd Sheen

Jul 3 '07 #1
6 1538
"Lloyd Sheen" <a@b.cwrote in message
news:E1**********************************@microsof t.com...
Perhaps I have missed something but what I would like to do is have a more
"controlled" method of generating HTML from a web service.
What technique are you using now for generating HTML from a web service?

The usual way to do it is to have the web service return data, then to have
an ASP.NET page bind the data to controls which will produce the HTML.
--
John Saunders [MVP]

Jul 3 '07 #2

"John Saunders [MVP]" <john.saunders at trizetto.comwrote in message
news:uv**************@TK2MSFTNGP03.phx.gbl...
"Lloyd Sheen" <a@b.cwrote in message
news:E1**********************************@microsof t.com...
>Perhaps I have missed something but what I would like to do is have a
more "controlled" method of generating HTML from a web service.

What technique are you using now for generating HTML from a web service?

The usual way to do it is to have the web service return data, then to
have an ASP.NET page bind the data to controls which will produce the
HTML.
--
John Saunders [MVP]
At present I am just creating strings of the output HTML. I was looking for
a structured method using dotnet objects. Something like (just typed in so
most likely has errors)

<WebMethod()_
Public Function JustATest(ByVal Name As String) As String
Dim s As String = String.Empty

Dim tab As New HtmlTable
Dim r1 As New HtmlTableRow()
Dim c1 As New HtmlTableCell()
c1.InnerText = "Col1"
Dim c2 As New HtmlTableCell()
c2.InnerText = Name
r1.Cells.Add(c1)
r1.Cells.Add(c2)
tab.Rows.Add(r1)

dim s as string=string.empty
s=tab.??????
return s
End Function
????? would be a method name which would then issue the HTML to represent
the table and its contents.

Lloyd Sheen
Jul 3 '07 #3
This post shows how you can render the content of servercontrols to a string
using the RenderControl method.

http://petesbloggerama.blogspot.com/...ntrols-to.html

What you describe is really kind of a non-standard approach, but if that's
what you want to do, it should help.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder(BETA): http://www.blogmetafinder.com

"Lloyd Sheen" wrote:
>
"John Saunders [MVP]" <john.saunders at trizetto.comwrote in message
news:uv**************@TK2MSFTNGP03.phx.gbl...
"Lloyd Sheen" <a@b.cwrote in message
news:E1**********************************@microsof t.com...
Perhaps I have missed something but what I would like to do is have a
more "controlled" method of generating HTML from a web service.
What technique are you using now for generating HTML from a web service?

The usual way to do it is to have the web service return data, then to
have an ASP.NET page bind the data to controls which will produce the
HTML.
--
John Saunders [MVP]

At present I am just creating strings of the output HTML. I was looking for
a structured method using dotnet objects. Something like (just typed in so
most likely has errors)

<WebMethod()_
Public Function JustATest(ByVal Name As String) As String
Dim s As String = String.Empty

Dim tab As New HtmlTable
Dim r1 As New HtmlTableRow()
Dim c1 As New HtmlTableCell()
c1.InnerText = "Col1"
Dim c2 As New HtmlTableCell()
c2.InnerText = Name
r1.Cells.Add(c1)
r1.Cells.Add(c2)
tab.Rows.Add(r1)

dim s as string=string.empty
s=tab.??????
return s
End Function
????? would be a method name which would then issue the HTML to represent
the table and its contents.

Lloyd Sheen
Jul 3 '07 #4
"Lloyd Sheen" <a@b.cwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>
"John Saunders [MVP]" <john.saunders at trizetto.comwrote in message
news:uv**************@TK2MSFTNGP03.phx.gbl...
>"Lloyd Sheen" <a@b.cwrote in message
news:E1**********************************@microso ft.com...
>>Perhaps I have missed something but what I would like to do is have a
more "controlled" method of generating HTML from a web service.

What technique are you using now for generating HTML from a web service?

The usual way to do it is to have the web service return data, then to
have an ASP.NET page bind the data to controls which will produce the
HTML.
--
John Saunders [MVP]

At present I am just creating strings of the output HTML. I was looking
for a structured method using dotnet objects. Something like (just typed
in so most likely has errors)

<WebMethod()_
Public Function JustATest(ByVal Name As String) As String
Dim s As String = String.Empty

Dim tab As New HtmlTable
Dim r1 As New HtmlTableRow()
Dim c1 As New HtmlTableCell()
c1.InnerText = "Col1"
Dim c2 As New HtmlTableCell()
c2.InnerText = Name
r1.Cells.Add(c1)
r1.Cells.Add(c2)
tab.Rows.Add(r1)

dim s as string=string.empty
s=tab.??????
return s
End Function
????? would be a method name which would then issue the HTML to represent
the table and its contents.
Well, as I said earlier, the usual way is to separate the presentation
(HTML) from the data and business logic (the web service). That's why people
usually use ASP.NET for this purpose.
--
John Saunders [MVP]

Jul 3 '07 #5

"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:BA**********************************@microsof t.com...
This post shows how you can render the content of servercontrols to a
string
using the RenderControl method.

http://petesbloggerama.blogspot.com/...ntrols-to.html

What you describe is really kind of a non-standard approach, but if that's
what you want to do, it should help.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder(BETA): http://www.blogmetafinder.com

"Lloyd Sheen" wrote:
>>
"John Saunders [MVP]" <john.saunders at trizetto.comwrote in message
news:uv**************@TK2MSFTNGP03.phx.gbl...
"Lloyd Sheen" <a@b.cwrote in message
news:E1**********************************@microsof t.com...
Perhaps I have missed something but what I would like to do is have a
more "controlled" method of generating HTML from a web service.

What technique are you using now for generating HTML from a web
service?

The usual way to do it is to have the web service return data, then to
have an ASP.NET page bind the data to controls which will produce the
HTML.
--
John Saunders [MVP]

At present I am just creating strings of the output HTML. I was looking
for
a structured method using dotnet objects. Something like (just typed in
so
most likely has errors)

<WebMethod()_
Public Function JustATest(ByVal Name As String) As String
Dim s As String = String.Empty

Dim tab As New HtmlTable
Dim r1 As New HtmlTableRow()
Dim c1 As New HtmlTableCell()
c1.InnerText = "Col1"
Dim c2 As New HtmlTableCell()
c2.InnerText = Name
r1.Cells.Add(c1)
r1.Cells.Add(c2)
tab.Rows.Add(r1)

dim s as string=string.empty
s=tab.??????
return s
End Function
????? would be a method name which would then issue the HTML to represent
the table and its contents.

Lloyd Sheen
Thanks Peter, your method worked great. I just put it to a memory stream to
extract the HTML. I am using AJAX to call the webservice directly and then
populate a DIV with the output without having to do things like send
viewstate and whatever. I know what needs to be sent and this method is
much faster than a postback.

Thanks again this will stay in my bag of tricks.
Lloyd Sheen

Jul 3 '07 #6
you can always make use of RenderControl method to get the html:

' first create a memory stream to hold the output
Dim ms As New System.IO.MemoryStream
' now open HTML Text Writer
Dim writer As New System.Web.UI.HtmlTextWriter(New System.IO.StreamWriter(ms))
writer.BeginRender()
myHtmlTableControl.RenderControl(writer)
writer.EndRender()
writer.Flush()
' now reposition stream to the start
ms.Position = 0
Dim sr As New System.IO.StreamReader(ms)
Dim html As String = sr.ReadToEnd()
"Lloyd Sheen" wrote:
Perhaps I have missed something but what I would like to do is have a more
"controlled" method of generating HTML from a web service.

I can create items using HtmlTable, HtmlTableRow, and HtmlTableCell but is
there a quick method once the table has been built to get the HTML, put it
in a string for return the browser call for the web service?

I notice that HtmlTable does not support InnerHtml so that is not doable.

Ideas??

Thanks
Lloyd Sheen
Jul 4 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dan Gass | last post by:
The difflib.py module and the diff.py tools script in Python 2.4 alpha 3 now support generating side by side (with intra line differences) in HTML format. I have found this useful for performing...
8
by: Lars Netzel | last post by:
Hey! I wrote a message yersterday and got some good answers and have now managed to generate a nice image. The problem is that it's all generated in an Images.Aspx file and I don't really want...
4
by: Water Cooler v2 | last post by:
How do you create a .wsdl file for a Web Service you are developing using Visual Studio .NET 2003?
1
by: Ryan Ginstrom | last post by:
I have been maintaining a body of documentation in plain HTML files. I would now like to automate the generation of the HTML files. Maintaining the HTML files now is tedious and error prone,...
1
by: idletask | last post by:
Hello, I have an XML file that is on my file system. I want to read the file into memory and call a web service with it. When I do, the VB complains: "there was an error generating the XML...
0
Sakalicek
by: Sakalicek | last post by:
Hi all, I have following problem in my application. I have Web Service and project which uses methods from this Web Service. I created proxy WsProxy by wsdl.exe and put it into that project. But...
1
by: Nathan Sokalski | last post by:
Visual Studio 2005 recently stopped generating the *.designer.vb files for my *.aspx and *.ascx files. I am using Service Pack 1, and do not believe I did anything differently than normal prior to...
0
by: g-forsmo | last post by:
Hi! I am trying to implement a web service after a wsdl generated from BEA Web logic. I have used a tool called WSCF - Schema-Based Contract- First Web Services to generate a web service from a...
0
by: khurramlone | last post by:
I am trying to generate a client proxy from a WCF service library. I am using VS2005, .NET 3.0 on a Windows XP Pro workstation. The WCF service is hosted in a windows service. When I run the windows...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.