I have the same problem as this person:
The name 'controlname' does not exist in the current context
but with different effects.
Basically I am making a web page in which the one side has all these labels and forms which I will reference in the codebehind to generate an email and mail it to an admin.
Many people here stated that answers were deleting the designer file, or clicking convert to web application. I don't have a designer file and I don't have the convert option. Another was to put a "runat" in the html portion of the .aspx side. While it doesn't have that, it inherits a master page which has runats like
<asp:ContentPlaceHolder runat="server" ID="EntireBody">
In this example, all of the "XXX.Text" portions are errored, saying it does not exist in this context.
I'm a bit new at Visual Studio and making websites. What things should I do?
public partial class SendEmail : System.Web.UI.Page
{
protected void Submit_Click(object sender, EventArgs e)
{
MailMessage mailMsg = new MailMessage();
mailMsg.From = new MailAddress(txtContactEmail.Text);
mailMsg.To.Add("admin@email.com");
mailMsg.IsBodyHtml = true;
mailMsg.Subject = txtContractName.Text + " : " + txtCompanyName.Text + " : Software Enhancement";
mailMsg.Body = "Contact Details" + "<b>Name:</b>" + txtCompanyName.Text + " <br/> <b>Email - address :</b>" + txtContactEmail.Text + "<br/> <b>Comments :</b>" + txtSoftwareVersion.Text;
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
mailMsg.Priority = MailPriority.Normal;
smtp.Credentials = new System.Net.NetworkCredential("admin@email.com", "yourPassword");
smtp.Timeout = 25000;
smtp.EnableSsl = true;
smtp.Send(mailMsg);
ThankYou.Text = "Thank you. Your contact details and feed back has been submitted.";
}
}
.aspx side Markup
<%@ Page Title="Customer Support" Language="C#" MasterPageFile="~/members.master" AutoEventWireup="true" CodeFile="SoftwareEnhancement.aspx.cs" Inherits="support" %>