Send an Email inside a FormView

 I have a FormView that works but when I add a few <ASP:Textbox>'s to ask for Name and Phone number to request more info on this item

I get the following Error:

BC30451: Name 'Email' is not declared.

Inside a form view 

---ASPX Pagecode ----

      .....<div id="RequestInfo">
     For More Information Please Fill out this form.
      <asp:HiddenField ID="ITEMNUMB" Value='<%# Eval("ITEMNUM") %>' runat="server" />
          <asp:TextBox ID="Name" CssClass="RequestInput" TextMode="SingleLine" runat="server" TabIndex="1" /></p>
          <asp:TextBox ID="Email" CssClass="RequestInput" TextMode="SingleLine" runat="server" TabIndex="2" /></p> 
          <asp:TextBox ID="Phone" CssClass="RequestInput" TextMode="SingleLine" runat="server" TabIndex="3" /></p>
          <p><asp:Button ID="Submit" Text="Request More Info" onClick="btnClicked" runat="server" TabIndex="4" /></p>
      </div> ....


---.VB Page Behind ---


Sub btnRequestMoreInfo_Click(sender as Object, e as EventArgs)

        'Create an instance of the MailMessage class
  Dim SendMail as New MailMessage()

    'With SendMail
  'Set the properties - send the email to the person who filled out the form.
    .From = New MailAddress(Email.text)

   .IsBodyHtml = True
  'Set the subject
    .Subject = "Request Info From: " & Email.text
  'Set the body'
    .Body = "<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN>" & vbCrLf & _
"<html>" & vbCrLf & _
"<head>" & vbCrLf & _
"<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1>" & vbCrLf & _
"</head>" & vbCrLf & _
"<body>" & vbCrLf & _
"<p>" & Address.text & "</p>" & vbCrlf & _
"<p>" & Name.text & "<br />" & vbCrLf & _
"Email - " & Email.text & "<br />" & vbCrLf & _
"Phone - " & Phone.text & "<br />" & vbCrLf & _
"</body>" & vbCrLf & _

End With
    Dim client As SmtpClient = New SmtpClient("")
End Try
End Sub





5/4/2009 10:53:47 PM 72751 articles. 3 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 26

Hi Philip,

This is a very common situation in ASP.Net.  You are trying to reference a control by name that is contained within another container control, the FormView. In order to reference the inner control (Email), you must use the FormView's FindControl method:  

.From = New MailAddress(CType(MyFormView.FindControl("Email"), TextBox).Text)

Also, you can search Google or ASP.Net forums for "FindControl" if you need more information about this.

Hope this helps!


~ mellamokb

5/5/2009 1:28:20 AM

Similar Artilces:

Controls inside formview inside formview
Hello, I'm trying to insert data into a label that is located in a formview which is located in a formview.  This is what I got so far: Private Sub Test()    Dim fvSecondView As New FormView    fvSecondView = Me.FormView1.FindControl("SecondView")    Dim lblData As New Label    lblData = fvSecondView.FindControl("DataLabel")    lblData.Text = "Some Data" End Sub Now this does work to get data out if I change the last line to: testlabel.text = lblData.Text But just can't seem to get the data to go ...

How do I control parameter a control that is inside a formview that has another formview in it?
I have a formview2 within another formview1 but I want to control parameter from a sqlDataSource3 outside the formview a control that is in formview2<asp:SqlDataSource ID="SqlDataSource1" SelectCommand='SELECT "USER,UID" FROM "TUSERS"'><asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1">    <ItemTemplate>        <asp:Label ID="Label1" runat="server" Text='<%# Bind("USER") %>'></asp:La...

SqlDataSource with FormView: Referencing a control inside FormView as control parameter?
I have been looking at this website and was wondering...what if my FormView control had a textbox or label inside of it in its EditTemplate item...can I link my SqlDataSource object (which is also bound to the FormView control) to that control meaning specify control parameter as the textbox which is inside the FormView...? PS: I use vbexpress 2005 programming blog Hi:   You can try something like: <asp:ControlParameter ControlID="FromView1$DropDownList1"   But please make sure the DropDownList (or any other controls) be available all the time. In anoth...

Referencing Nested FormView Control inside the EmptyDataTemplate of a FormView Control
Hi all,I am very new to ASP.Net and have been working on a particularly frustrating problem now for days and cant seem to find an answer to it. I am building a front end to a newly created database and have set 2 session variables that I am using to set default values using the FindControl Method. this works fine until I need to set default values in a nested control. IE...I have a form view control and in that controls EmptyDataTemplate I have another form view control with about 10 fields using the same datasource as the parent form view. I need to place default values in 2 of those fields...

Formview inside a formview controller
Hi all, I'm using a formview(say formview1) controller to insert a records to a table. I take a value from a dropdownlist which i have placed in  the InsertItemTemplete of the formview1. Lets say the dropdownlist has list of towns and I need to add a new town to the list while the user is in the insert template. To do this I have added another formview (say formview2) to inser a new record to the towns table. My problem is my dropdown list is not getting updated just after I have added a new town. But if I start insert operation all over again then I can see the new town. I know t...

controls not visible inside formview control
I am trying to write a query to select data from one table based on the resultof a drop down list that pulls data from another table. The query I am writing is: "SELECT church.churchName, church.churchId AS Expr1 FROM [churches]WHERE ([deanery.deaneryId] = @churches.deaneryId)"I am using a sql source controlNow I found an example from a website that pulls data from one drop down list and usesthe selected value to populate the second drop down list. But, the controls are not part of a formviewcontrol. So my question is how do I get the dropdownlist control that is located...

How I can accede to the controls that they find inside a formview from VB.NET
Hi again: How I can accede to the controls that they find inside a formview, to use its values, to modify or validate it, from  VB.NET. For example I have the next page Items.aspx: <table border="0" cellspacing="0" cellpadding="0">     <tr>        <td><asp:TextBox runat="server" ID="MinIDProducto" Text="" /> </td>        <td></td>     </tr>     <tr>        <td><asp:Tex...

ready made tool or control in .net for sending mass email upto 5000
 hello everyone        i want some ready made tool or control in .net for sending mass email upto  5000for both windows and web can u  suggest me one thanks  Satyabrat SinghB.E.(C.Sc.)Web developer Livetek Solution Dont forget to click "Mark as Answer" on the post that helped you. Hi,There is no such tool available. You need to develop it for yourself. Or elseYou can try various bulk mailing sites like Constant Contacts etc whether they provide any API for the sameMy domain is Email marketing and I have developed the applicat...

Sending Email with Net.Mail (No Email, no error)
hi,i'm using the namespace to send an email from my application. when i send, the application does not fire any exception, neither does it send the email to my account.below is the code i'm using  Dim mmailMessage As New Net.Mail.MailMessage Dim mFrom As New Net.Mail.MailAddress(mailFrom) mmailMessage.From = mFrom Dim ll As String = "" mmailMessage.To.Add(ll) mmailMessage.Subject = "Talk Concerns" mmailMessage.Body = "Testing Concerns One Two" Dim ...

Finding a controls inside a FormView which is inside a MasterPage
Hi, I have few controls (textboxes) inside a FormView that is inside a MasterPage. The findcontrol doesn't work for me or I'm not doing it right. If I JUST use the FormView or JUST the MasterPage then the findcontrol works. For example TextBox idTextBox = (TextBox)FormView1.FindControl("TextBox1"); works if I don't use the MasterPage. Can someone please help? How do you find a control inside the FormView1 that is inside the MasterPage? Any help would be appreciated. Hi, friend:   Try this:         FormViewRow fr = ((FormView)Master.FindCont...

i am using login controls in vidual dev 2005 .net 2 and want to send an email... however
even though i have added this to we.config <>    <mailSettings>      <smtp deliveryMethod="PickupDirectoryFromIis"/>    </mailSettings>  </> it is not working. How do i enable the local SMTP server. I have looked in IIS and it is ticked use localhost port 25. Authentication settings set to NOT REQUIRED. Is all this correct? Can anyone help Define what you mean by "not working."  Check SMTP logs.  Test SMTP with Outlook or another client.  And te...

Sending Email by Control Name Rather Than Control Content
 Hi, there, I am building a Contact Us by sending an email. Everything is going fine except the email I received has all the control names rather than user input. The code is like this when Send button clicked:        MailMessage objEmail = new MailMessage();        objEmail.From = new MailAddress(txtEmail.Text);        objEmail.To.Add("");        objEmail.Subject = "Message From Web Contact - " + txtEmail; ...

Formview inside Wizard which is inside FormView
Hi, I have a FormView which contains a Wizard which contains some databinding controls in its steps like Gridview,FormView,...and their ObjectDataSource controls I want these controls to perform their insert,update methods only when the Wizard finish button is clicked.Is this possible?  About putting the whole wizard inside a FormView I did this to be able to use Bind+Eval but it is the first time Iam using the wizard control. Hi TheEagle , Try something like this :   protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) ...

FileUpload control inside UpdatePanel inside user control inside popup
Hi,     The Asp.Net File Upload control is not working inside update panel. Acutally i have put the FileUpload control inside User Control again inside update panel. Since the update panel does async postback. The posted file is null in the server side. When i do full page level post back it works. but i have to put it inside update panel. How to do it? Becuase the FileUpload control should be in Ajax Model Popup Extender where i have to put update panel to avoid closing of popup after fullpostback. Since the ajax model popup extender is getting closed after full post b...

Web resources about - Send an Email inside a FormView -

Visual Studio 2008 and .NET Framework 3.5 Service Pack 1 Beta
In this article, Scott discusses the recently released beta version of Visual Studio 2008 and .NET Framework 3.5 Service Pack 1. He starts with ...

Visual Studio 11 Beta in Context
... data controls. I blogged about this before in my Elegant Web Forms post . There's two way data-binding in controls like the FormView now instead ...

Visual Studio General Questions Forum
Sign in Home Samples Languages Extensions Documentation Community Forums CodePlex User Voice File a Bug Get started for free Visual Studio Developer ...

Advanced Residential Search

Keep, share, and discover the best of the Web using Delicious, the world's leading social bookmarking service.

ASP.NET Web Forms DynamicData FieldTemplates for DbGeography Spatial Types
... - 10 Tutorials Mixing Razor Views and WebForms Master Pages with ASP.NET MVC DbGeography FieldTemplates for ASP.NET Web Forms Here's a FormView ...

Resources last updated: 11/22/2015 12:27:19 PM