Community Support & Help Center for Hosting, Dedicated Services, Colocation, Design & Development
Hosting, Dedicated Services, Colocation, Design & Development

Simple ASP.Net VB Contact Form

This post has 0 Replies | 1 Follower

Top 10 Contributor
Male
Posts 242
Shawn Hyde Posted: 06-04-2008 5:39 PM

This is a Quick example of how you can create an VB.net contact form.

Example: simple vb.net contact form no css

Your_Contact_Page.aspx Code:

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Web.Mail" %>
<script runat="server">   

   Sub btnSubmit_Click(sender as object, e as EventArgs)

        Dim objEMail As New MailMessage()
       
        objEMail.To = "enter the email address you want to send to here"
        objEmail.From = txtFrom.Text
  
  objEmail.Subject = txtSubject.Text
  objEmail.Body = "Real IP: " & Request.ServerVariables("HTTP_X_FORWARDED_FOR") & vbcrlf & "IP: " & Request.ServerVariables("REMOTE_ADDR") & vbcrlf & "Date/Time: " &Now & vbcrlf & "Name: " &txtName.Text & vbcrlf & "Email: " &txtFrom.Text & vbcrlf & "Comments: " &txtBody.Text
  objEmail.Priority = MailPriority.High
        SmtpMail.SmtpServer = "Enter your mail server domain here"

  try
   SmtpMail.Send(objEMail)
   'Success Options: (uncomment one of these)
   'Response.Write("success")
   'Response.Redirect("/success page")
  
  catch exc as Exception
   Response.Write("Send failure: " + exc.ToString())
  End Try
    End Sub
</script>
<!-- Simple Email Form Code Copyright &copy;1998-2008 Area51 Computers / Services. Any customer of Area51 may use this code in conjunction with Area51.mn hosting services. This notice must remain in tact at all times. -->
<html>
<head>
<title>Simple contect form</title>
</head>
<body>

<form id="ContactMain" runat="server">
<table width="600" border="0" align="center" cellpadding="3" cellspacing="0">
     <tr>
       <td height="24" colspan="2" align="right" valign="top">&nbsp;</td>
    </tr>
     <tr>
      <td width="28%" align="right" valign="top">Name :</td>
      <td width="72%" height="24" valign="top">
      <asp:TextBox runat="server" Width="200px" ID="txtName"></asp:TextBox>      </td>
     </tr>
     <tr>
       <td align="right">Email :</td>
       <td height="24" valign="top"><asp:TextBox runat="server" Width="200px" ID="txtFrom" ></asp:TextBox>                        </td>
    </tr>
     <tr>
      <td align="right">Subject : </td>
      <td height="24" valign="top"><asp:TextBox runat="server" Width="200px" ID="txtSubject" ></asp:TextBox></td>
       </tr>
     <tr>
       <td align="right" valign="top">Comments : <br>
          <br></td>
       <td valign="top"><asp:TextBox runat="server" TextMode="MultiLine" Height="80px" Width="250px" ID="txtBody"></asp:TextBox>                                                </td>
       </tr>
     <tr>
       <td colspan="2" align="center">Proxy(<% = Request.ServerVariables("HTTP_X_FORWARDED_FOR")%>
         ) IP(
           <% = Request.ServerVariables("REMOTE_ADDR")%>
           ) Validation &amp; Time Stamp :
           <% = Now %>
</td>
    </tr>
     <tr>
      <td colspan="2" valign="top" height="30">
      <p align="center">


   <asp:Button Runat = server ID = btnSubmit OnClick = btnSubmit_Click Text = "Submit"></asp:Button>
      &nbsp;<input type = "reset" value = "Clear" runat = "server">
    </td>
     </tr>
     </table>
<br>
</form>
<center>
</center>

</body>
</html>

 

Page 1 of 1 (1 items) | RSS
©1998-2009 · Area51 Computers/Services, all rights reserved.