我複製了一箇舊窗體並使用不同的字段創建了這個新窗體,現在收到以下錯誤消息。CS0103:名稱'EmailCollections'在當前上下文中不存在
\ WWW \資產\根\形式\ revenueanalysis.aspx.cs(50,13):錯誤CS0103:名稱 'EmailCollections' 不存在於當前上下文
\ WWW \資產存在\根\ forms \ revenueanalysis.aspx.cs(61,18):錯誤CS0103:名稱'Utility'在當前上下文中不存在
\ www \ assets \ root \ forms \ revenueanalysis.aspx.cs(74,18 ):錯誤CS0103:當前上下文中不存在名稱'Utility'
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Net.Mail;
using System.Web.Mail;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.IO;
using System.Linq;
public partial class revenueanalysis : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (IsFormValid())
{
string name = string.Empty;
string emailAddress = string.Empty;
string emailAddress2 = string.Empty;
string phone = string.Empty;
string title = string.Empty;
string company = string.Empty;
string comment = string.Empty;
string specialties = string.Empty;
string cases = string.Empty;
name = tbName.Text;
emailAddress = tbEmail.Text;
emailAddress2 = tbEmail2.Text;
phone = tbPhone.Text;
title = tbTitle.Text;
company = tbCompany.Text;
comment = tbComment.Text;
specialties = tbSpecialties.Text;
cases = tbCases.Text;
EmailCollections.SendNewrevenueanalysisFormEmail(name, emailAddress, emailAddress2, phone, title, company, comment, specialties, cases, this);
}
}
private bool IsFormValid()
{
bool isvalid = true;
if (string.IsNullOrEmpty(tbName.Text)) { isvalid = false; lblName.CssClass = "error"; } else { lblName.CssClass = ""; }
if (string.IsNullOrEmpty(tbEmail.Text)) { isvalid = false; lblEmail.CssClass = "error"; }
else
{
if (!Utility.IsEmailValid(tbEmail.Text))
{
isvalid = false;
lblEmail.CssClass = "error";
}
else
{
lblEmail.CssClass = "";
}
}
if (string.IsNullOrEmpty(tbEmail2.Text)) { isvalid = false; lblEmail.CssClass = "error"; }
else
{
if (!Utility.IsEmailValid(tbEmail2.Text))
{
isvalid = false;
lblEmail.CssClass = "error";
}
else
{
lblEmail.CssClass = "";
}
}
if (string.IsNullOrEmpty(tbPhone.Text)) { isvalid = false; lblPhone.CssClass = "error"; } else { tbPhone.CssClass = ""; }
if (string.IsNullOrEmpty(tbTitle.Text)) { isvalid = false; lblTitle.CssClass = "error"; } else { tbTitle.CssClass = ""; }
if (string.IsNullOrEmpty(tbCompany.Text)) { isvalid = false; lblCompany.CssClass = "error"; } else { tbCompany.CssClass = ""; }
if (string.IsNullOrEmpty(tbComment.Text)) { isvalid = false; lblComment.CssClass = "error"; } else { tbComment.CssClass = ""; }
return isvalid;
}
}
-----更新----- 這是我複製的代碼,它看起來像所有'使用'語句是相同的。這種形式正常運作。
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Net.Mail;
using System.Web.Mail;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.IO;
using System.Linq;
public partial class RequestProposal : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (IsFormValid())
{
string name = string.Empty;
string emailAddress = string.Empty;
string phone = string.Empty;
string message = string.Empty;
string cases = string.Empty;
string specialties = string.Empty;
string nOperatingR = string.Empty;
string nProcedureR = string.Empty;
string state = string.Empty;
name = tbName.Text;
emailAddress = tbEmail.Text;
phone = tbPhone.Text;
message = tbComment.Text;
cases = tbCases.Text;
specialties = tbSpecialties.Text;
nOperatingR = tbOperatingR.Text;
nProcedureR = tbProcedureR.Text;
state = tbState.Text;
EmailCollections.SendNewRequestProposalFormEmail(name, emailAddress, phone, message, cases, specialties, nOperatingR, nProcedureR, state, this);
}
}
private bool IsFormValid()
{
bool isvalid = true;
if (string.IsNullOrEmpty(tbName.Text)) { isvalid = false; lblName.CssClass = "error"; } else { lblName.CssClass = ""; }
if (string.IsNullOrEmpty(tbEmail.Text)) { isvalid = false; lblEmail.CssClass = "error"; }
else
{
if (!Utility.IsEmailValid(tbEmail.Text))
{
isvalid = false;
lblEmail.CssClass = "error";
}
else
{
lblEmail.CssClass = "";
}
}
if (string.IsNullOrEmpty(tbComment.Text)) { isvalid = false; lblComment.CssClass = "error"; } else { tbComment.CssClass = ""; }
return isvalid;
}
}
您複製的頁面似乎是「部分」的 - 您確定您還複製了其他部分嗎? –
是的,你似乎沒有包括或構建任何電子郵件收藏或實用程序 –
我很抱歉,我有這個網站傾倒在我身上,我不熟悉c#。其他兩種使用相同代碼的表單(emailcollections和utility)仍然可以正常工作,我是否需要在某處定義「收入分析」? – Ryeboflaven