2013-03-21 87 views
1

首先,我知道這個問題看起來非常相似的問題here名稱「txtinput1」不在當前情況下存在

但是不知怎麼的修正建議;隨行爲我工作。所以在這裏。 我有下面的代碼 在我的aspx頁面:

<asp:TextBox ID="txtinput1" runat="server" Width="200px" 
     ontextchanged="txtinput1_TextChanged"></asp:TextBox> 

但是當我嘗試下面的代碼在我後面的代碼:

protected void Page_Load(object sender, EventArgs e) 
     { 
      StemService.ServiceClient myClient = new StemService.ServiceClient(); 
      string input = txtinput1.Text; 
     } 

我得到的錯誤,說「txtinput1」不存在在上下文中。 爲了完成這裏是我的default.aspx https://gist.github.com/KodeSeeker/5217410

P.S.我是C#noob,所以我可能會失去一些明顯的東西。

編輯:Designer.cs https://gist.github.com/KodeSeeker/5217484

編輯2:Default.aspx.cs:https://gist.github.com/KodeSeeker/5217517

+1

檢查設計師的正確申報.cs文件以查看是否已添加... – 2013-03-21 22:37:48

+0

請檢查編輯。它似乎存在於其中。 – KodeSeeker 2013-03-21 22:41:51

+0

你也可以添加.cs文件嗎? – 2013-03-21 22:44:45

回答

3

你designer.cs似乎缺少命名空間

namespace Project3_ConsumptionApplication 
{ 
    ... 
} 
+0

感謝您的回答,代碼似乎沒有顯示任何編譯時錯誤,但Intellisense似乎仍然沒有檢測到該字段,這是正常的嗎?或者以後會有問題? – KodeSeeker 2013-03-21 22:59:00

+0

但是如果添加命名空間問題就解決了嗎? – Steve 2013-03-21 22:59:43

+0

當我添加命名空間時,錯誤消失。我不確定它是否會正常運行。這裏是修改過的設計器(你可以仔細檢查)https://gist.github.com/KodeSeeker/5217607 – KodeSeeker 2013-03-21 23:02:05

相關問題