gtjr921
Programmer
- Aug 30, 2006
- 115
Asp.net 1.1
I am trying to create a contact form with asp.net 1.1 page and a vb code behind. when i reference a control in my vb code it acts as if it does not know what controls i am referencing I get "Name 'txtFrom' is not declared"
I get this for any aspx control I call in my vb code.
Here is my code
Asp.net page relevant code
I am trying to create a contact form with asp.net 1.1 page and a vb code behind. when i reference a control in my vb code it acts as if it does not know what controls i am referencing I get "Name 'txtFrom' is not declared"
I get this for any aspx control I call in my vb code.
Here is my code
Code:
'vb code behind contact.vb
Imports System.Web.Mail
Imports System.Web.Mail.MailMessage
Public Class WebForm1
Inherits System.Web.UI.Page
Public Sub Btnsend_click(ByVal sender As Object, ByVal e As eventargs)
Dim objEmail As New MailMessage()
objEmail.To = "myemail@here.com"
objEmail.From = txtFrom.Text
'objEmail.Cc = txtCc.Text
objEmail.Subject = "subject Email"
objEmail.Body = txtName.Text & ", " & txtMSG.Text
objEmail.Priority = MailPriority.High
SmtpMail.SmtpServer = "123.456.789.1"
Try
SmtpMail.Send(objEMail)
Response.Write(Your E-mail to has been sent _ ) Catch exc As Exception
Response.Write("Send failure: " + exc.ToString())
End Try
End Sub
End Class
Asp.net page relevant code
Code:
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" codebehind="contact.vb" Src="contact.vb" Inherits="WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<asp:TextBox id="txtFrom" runat="server" TextMode="SingleLine"></asp:TextBox>
<asp:Label id="lblMsg" runat="server"
text="Type Your Message Here"></asp:Label>
<br />
<asp:TextBox id="txtMSG" runat="server" TextMode="MultiLine" Height="186px" Width="552px"></asp:TextBox>
<br />
<br />
<asp:Button id="btnSend" runat="server" Text="Send Email" onclick="Btnsend_click"></asp:Button>