Button1_Click method doesn't exist

  • Thread starter Thread starter Bali
  • Start date Start date
B

Bali

Hi

I have an ascx control through which I am calling an aspx page using
the following command.

Page.ClientScript.RegisterStartupScript(GetType(), "test",
"window.open(...)");

Initially I just added a label controls on the page and it opened up
fine without any errors.

I then have added a button to the aspx page. When I double click on
the button in design mode, I am transferred to the codebehind class to
the button click event handler ( protected void Button1_Click(object
sender, EventArgs e){}).

Now when I run the application and get to the point where the ascx is
calling the aspx page I get an error saying that there doesn't exist a
Button1_Click method. I have checked the code behind and the method
exists there, I can get to the method by double clicking in design
mode and I have already tried removing and readding the button and
that didn't work either. I can't figure out what the issue is here and
any help regarding this would be greatly appreciated.

Thanks

Sumeet
 
Hi

I have an ascx control through which I am calling an aspx page using
the following command.

Page.ClientScript.RegisterStartupScript(GetType(), "test",
"window.open(...)");

Initially I just added a label controls on the page and it opened up
fine without any errors.

I then have added a button to the aspx page. When I double click on
the button in design mode, I am transferred to the codebehind class to
the button click event handler ( protected void Button1_Click(object
sender, EventArgs e){}).

Now when I run the application and get to the point where the ascx is
calling the aspx page I get an error saying that there doesn't exist a
Button1_Click method. I have checked the code behind and the method
exists there, I can get to the method by double clicking in design
mode and I have already tried removing and readding the button and
that didn't work either. I can't figure out what the issue is here and
any help regarding this would be greatly appreciated.

Thanks

Sumeet

Does aspx work when you call it directly as http://.../page.aspx?
 
Does aspx work when you call it directly ashttp://.../page.aspx?- Hide quoted text -

- Show quoted text -

Apparently not. If I type http://localhost/..../webform2.aspx in IE, I
get the same error.

Compilation error.

Description: An error occured during the compilation of a resource
required to service the request....

Compiler Error Message: ...webform2_aspx does not contain a definition
for 'Button1_Click'

and if I open up the solution in VS2005 and set webform2 as the
startup page and run it, the page opens up fine and the button click
event works as well.

Any ideas?

Thanks for looking into this.

Sumeet
 
Apparently not. If I typehttp://localhost/..../webform2.aspxin IE, I
get the same error.

ok, it means it doesn't matter from where you call it

How did you create the webform? Maybe you did change the namespace or
a name of the class? Check if Namespace.Class from <%@ Page
Inherits="Namespace.Class" is the same as in the code behind. Check if
the AutoEventWireup attribute of the Page directive is set to true (if
it is missing by default it is true). If you see nothing wrong, try to
rename the webform2.aspx to webform2_.aspx and create new
webform2.aspx.
 
ok, it means it doesn't matter from where you call it

How did you create the webform? Maybe you did change the namespace or
a name of the class? Check if Namespace.Class from <%@ Page
Inherits="Namespace.Class" is the same as in the code behind. Check if
the AutoEventWireup attribute of the Page directive is set to true (if
it is missing by default it is true). If you see nothing wrong, try to
rename the webform2.aspx to webform2_.aspx and create new
webform2.aspx.

Hi

I tried all of the above and still none worked! Any other things that
you can think of coz I am surely running out of ideas.

Thanks

Sumeet
 
Back
Top