Rafael Sanchez Rafael Sanchez - 1 month ago 4x
ASP.NET (C#) Question

How to Display string text in html body?

I'm just starting with ASP.NET, C# and HTML.

I want to display a text message in the browser if an email was sent successfully.

How do I show in the HTML body the value of a variable that was previously defined in the script part of the


<script runat="server">
void SendAnEmail()
string theResult = "Success! :)";
catch (System.Net.Mail.SmtpException)
string theResult = "Failure! :(";
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Send Mail</title>
<form id="form1" runat="server">


You may want to use the asp:Literal server control which it's syntax is: <asp:Literal runat="server" ID="LiteralText"/>

And assign text to it in code behind: LiteralText.Text = theResult;