Using html in C# code  
Author Message
robertje





PostPosted: Visual C# General, Using html in C# code Top

Is there a way to use html in a C# application

I would like to use html in my app without having to use + quote + a few hundred times.



Visual C#15  
 
 
cverdon





PostPosted: Visual C# General, Using html in C# code Top

Hi,

If you are not developping a ASP.NET app, the most elegant solution is to have the html in template files.

ClientOrders.template

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

<head>

<title></title>

</head>

<body>

<div>Hello {FirstName} {LastName}</div>

<h1>Orders</h1>

<div>You have {NumberOfOrders}:</div>

{Orders}

</body>

</html>

Order.template

<div>

<div>Order: {OrderId}</div>

<div>SubTotal: {OrderSubTotal}</div>

<div>Taxes: {OrderTaxes}</div>

<div>Total: {OrderTotal}</div>

</div>

In you app you simply load the file contents and use the Replace function to replace all the keys with your values. In the case of the orders, you first create the list of orders by repeatedly using the Order template in a loop.

Regards,
Charles


 
 
RizwanSharp





PostPosted: Visual C# General, Using html in C# code Top

You question is a little bit ambigious, What do you mean by using HTML in C# code Do you need to Show HTML from any source OR you Need to GEnerate HTML using code and then Show it What do you mean by + quote + IS it " ".....

Sorry but you question doesnot explain much.

Let me try to answer your question :),

If you need to Display the HTML, you can use BrowserControl and load your pre build HTML in it using Navigate function..

If you want to load and HTML from any wehpage on the Web you can load it in the same way as above.

YOu want to generate HTML using Code, YOu can use StringBuilder class to append the HTML in String Builder Efficiently and then Write all the srring to a file using StreamWriter class .......

I hope anyone of above solution will suite your need.

Best Regards,

Rizwan