HTML:如何獲得一個文本框的值在代碼隱藏
<input type="text" runat="server" value="" placeholder="Search" id="searchB" class="styledTB searchB floatLeft" />
C#:
string strSMain;
protected void Page_Load(object sender, EventArgs e)
{
tbSearchMain = (System.Web.UI.WebControls.TextBox)sender;
strSMail = tbSearchMain.text; // gives me the following error: Exception Details: System.InvalidCastException: Unable to cast object of type 'ASP.site_master' to type 'System.Web.UI.WebControls.TextBox'.
strSMain = searchB.text; //.Text is not an option for me
}
請幫我解決這個問題。
我正在創建一個web應用程序。該控件位於MasterPage中。
你能提供整個代碼請。謝謝。 – SearchForKnowledge 2014-11-21 17:23:35
我腦凍結了。我只能使用'searchB.Value'; – SearchForKnowledge 2014-11-21 17:25:36
這有道理@SearchForKnowledge? – techvice 2014-11-21 17:25:47