2015-06-23 123 views
0

我複製了一箇舊窗體並使用不同的字段創建了這個新窗體,現在收到以下錯誤消息。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; 
    } 
} 
+0

您複製的頁面似乎是「部分」的 - 您確定您還複製了其他部分嗎? –

+0

是的,你似乎沒有包括或構建任何電子郵件收藏或實用程序 –

+0

我很抱歉,我有這個網站傾倒在我身上,我不熟悉c#。其他兩種使用相同代碼的表單(emailcollections和utility)仍然可以正常工作,我是否需要在某處定義「收入分析」? – Ryeboflaven

回答

0

您試圖訪問對象「EmailCollections」你btnSubmit_Click方法的末尾:

EmailCollections.SendNewrevenueanalysisFormEmail(name, emailAddress, emailAddress2, phone, title, company, comment, specialties, cases, this); 

您還試圖訪問在多個地方一個「實用」的對象:

if (!Utility.IsEmailValid(tbEmail.Text)) 

您收到的錯誤是因爲系統不知道在哪裏找到這些對象。是否有可能當你複製舊的時候,你在頂部丟失了一些「使用」語句,這些語句指向缺少的對象的命名空間?如果你仍然有舊的副本,我會建議檢查「使用」語句,幷包括那些包含缺少的對象定義。

+0

我添加了我在OP中複製的代碼,它看起來都一樣。 – Ryeboflaven

+0

您可能想要檢查新項目是否也缺少舊項目中的任何必需參考。另外,正如其他人所說的那樣,這是一個部分類,因此您可能需要搜索該項目以查看該類在何處被定義(如果有的話),並查看是否有任何缺失的「使用」語句。 – Kevin

相關問題