0

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" %>
Community
  • 1
  • 1
Kiwizoom
  • 433
  • 1
  • 8
  • 21
  • This portion of code is a bit of a generic copy-paste I am trying to hammer into shape for the intended purpose. Some things I don't know what I will do with, like SmtpClient and the use of smtp.Credentials. – Kiwizoom Sep 12 '13 at 22:13
  • This issue is almost always a mismatch between your codebehind class name and the type declared in your aspx page. Can you show us the declarations at the top of your ASPX page? (the `<%@` tags) – Simon Whitehead Sep 12 '13 at 22:19
  • You say you don't have a designer file, can you post the ascx/aspx markup? – Robert Byrne Sep 12 '13 at 22:21
  • <%@ Page Title="Customer Support" Language="C#" MasterPageFile="~/members.master" AutoEventWireup="true" CodeFile="SoftwareEnhancement.aspx.cs" Inherits="support" %> – Kiwizoom Sep 12 '13 at 22:28

0 Answers0