This is the error:
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: The base class includes the field 'btnSearch', but its type (System.Web.UI.WebControls.Button) is not compatible with the type of control (System.Web.UI.WebControls.ImageButton).
Source Error:
Line 7: <li>
Line 8:
Line 9: <asp:ImageButton runat="server" ImageUrl="~/App_Themes/nopClassic/images/btn-search.gif" ID="btnSearch" OnClick="btnSearch_Click" Text="<% $NopResources:Search.SearchButton %>"
Line 10: CssClass="searchboxbutton" CausesValidation="false" />
Line 11: </li>
This is the code:
This is the cs page
protected System.Web.UI.WebControls.ImageButton btnSearch;
This is the ascx page
<asp:ImageButton runat="server" ImageUrl="~/App_Themes/nopClassic/images/btn-search.gif" ID="btnSearch" OnClick="btnSearch_Click" Text="<% $NopResources:Search.SearchButton %>"
CssClass="searchboxbutton" CausesValidation="false" />
The original ofcourse was Button instead of ImageButton.
This is the designer:
namespace NopSolutions.NopCommerce.Web.Modules {
public partial class SearchBoxControl {
protected global::System.Web.UI.WebControls.TextBox txtSearchTerms;
protected System.Web.UI.WebControls.Button btnSearch;
}
}
And this is .cs
namespace NopSolutions.NopCommerce.Web.Modules
{
public partial class SearchBoxControl : BaseNopUserControl
{
protected void btnSearch_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(txtSearchTerms.Text))
{
Response.Redirect(string.Format("~/search.aspx?searchterms={0}", HttpUtility.UrlEncode(txtSearchTerms.Text)));
}
}
protected override void OnPreRender(EventArgs e)
{
this.txtSearchTerms.Attributes.Add("onfocus", string.Format("if(this.value=='{0}')this.value=''", GetLocaleResourceString("Search.SearchStoreTooltip")));
txtSearchTerms.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + btnSearch.ClientID + "').click();return false;}} else {return true}; ");
base.OnPreRender(e);
}
}
}
Anyone knows how to fix it? Is it a bug?