Link to home
Create AccountLog in
Avatar of CipherIS
CipherISFlag for United States of America

asked on

ASP.NET C# - Convert User input to HTML

I am converting a client/server app to a web app.  In the client/server app the developer used a web browser to capture user input.  The purpose was to store the input in the database in HTML format which would be used to send an e-mail at some point.

I cannot use controls, unfortunately.  Anyone have any idea how I can duplicate a similar function after the user enters data in a textbox?

Would htmlencode work?
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

you create html template and simply replace the user input in the correct fields of the html.
Avatar of CipherIS

ASKER

Huh?
forget the template, if u use web application u can save the current web page with the user input as HTML file:
WebClient myClient = new WebClient();
string currentPageUrl = Request.Url.ToString();
UTF8Encoding utf8 = new UTF8Encoding();
byte[] requestHTML = myClient.DownloadData(currentPageUrl);
string myPageHTML = utf8.GetString(requestHTML);
 using (StreamWriter sw = new StreamWriter(Server.MapPath("~/user-input.html"), true))
 {
  sw.WriteLine(myPageHTML); // Write the html file.
 }    

Open in new window

I need to just convert what is in the text box to HTML.
ASKER CERTIFIED SOLUTION
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer