T
Tor Inge Rislaa
Invisible ASP.NET action
I have an .aspx page with some controls and a SEND button that are sending
an e-mail based on the content in some textbox's. Is it possible to call the
page with some parameters, so that the code sending the e-mail is executed
on the server without showing any page and the content from the textbox's is
replaced with the parameter values?
The code below is what I am testing on today:
<%@ Import Namespace="System.Web.Mail" %>
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1"
Debug="true" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Sending Mail</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script runat="server">
Sub Button_Click(s as Object, e as EventArgs)
Dim objMail = new MailMessage
objMail.From = "(e-mail address removed)"
objMail.To = email.Text
objMail.Subject = subject.Text
objMail.Body = "This is the body"
SmtpMail.SmtpServer = "localhost"
SmtpMail.Send(objMail)
End Sub
</script>
</head>
<body>
<h3>Sending Mail with IIS</h3>
<form action="frmSendingMail.aspx" method="post" name="form1" id="form1"
runat="server">
E-Mail:
<asp:TextBox Columns="30" ID="email" ReadOnly="false" TextMode="SingleLine"
runat="server" />
Subj:
<asp:TextBox Columns="30" ID="subject" TextMode="SingleLine"
runat="server"/> <br>
<br>
Send:
<asp:Button ID="btnSubmit" OnClick="Button_Click" runat="server" Text="Send"
value="" />
</form>
</body>
</html>
TIRislaa
I have an .aspx page with some controls and a SEND button that are sending
an e-mail based on the content in some textbox's. Is it possible to call the
page with some parameters, so that the code sending the e-mail is executed
on the server without showing any page and the content from the textbox's is
replaced with the parameter values?
The code below is what I am testing on today:
<%@ Import Namespace="System.Web.Mail" %>
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1"
Debug="true" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Sending Mail</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script runat="server">
Sub Button_Click(s as Object, e as EventArgs)
Dim objMail = new MailMessage
objMail.From = "(e-mail address removed)"
objMail.To = email.Text
objMail.Subject = subject.Text
objMail.Body = "This is the body"
SmtpMail.SmtpServer = "localhost"
SmtpMail.Send(objMail)
End Sub
</script>
</head>
<body>
<h3>Sending Mail with IIS</h3>
<form action="frmSendingMail.aspx" method="post" name="form1" id="form1"
runat="server">
E-Mail:
<asp:TextBox Columns="30" ID="email" ReadOnly="false" TextMode="SingleLine"
runat="server" />
Subj:
<asp:TextBox Columns="30" ID="subject" TextMode="SingleLine"
runat="server"/> <br>
<br>
Send:
<asp:Button ID="btnSubmit" OnClick="Button_Click" runat="server" Text="Send"
value="" />
</form>
</body>
</html>
TIRislaa