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