Button1_Click method doesn't exist


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
 
Ad

Advertisements

G

Guest

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?
 
B

Bali

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
 
G

Guest

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.
 
Ad

Advertisements

B

Bali

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top