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
}

Please help me resolve the issue.

I am creating a web application. And the control is in the MasterPage.

Related posts

Recent Viewed