user5468794 user5468794 - 10 months ago 41
HTML Question

Onclick event not working/redirecting

This is the first webservice I have made and I am having issues with my current functionality. My button in Visual Studio will only accept

without the error below. My button is defined as such in my .aspx:

<asp:Button ID="btnSearch" runat="server" OnClick="btnSearch_Click" Text="Search">

The aspx.cs file contains this:

protected void btnSearch_Click(object sender, EventArgs e)
Response.Redirect(""); //just for a testing

The error thrown is:

CS1061: 'ASP.main_aspx' does not contain a definition for
'btnSearch_Click' and no extension method 'btnSearch_Click' accepting a
first argument of type 'ASP.main_aspx' could be found

I have looked at various posts about
events and nothing I have tried has been the solution. Any ides on why when I click my button it doesn't redirect? Also I would like to use
rather than

Div Div

As per discussion in comment, issue is here:


Change it to


This will solved your error.