468,247 Members | 1,307 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,247 developers. It's quick & easy.

Button1_Click method doesn't exist

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

Oct 19 '08 #1
4 1868
On Oct 19, 12:04*pm, Bali <sumeetkb...@gmail.comwrote:
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?
Oct 19 '08 #2
On Oct 19, 7:03*am, Alexey Smirnov <alexey.smir...@gmail.comwrote:
On Oct 19, 12:04*pm, Bali <sumeetkb...@gmail.comwrote:


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 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
Oct 19 '08 #3
On Oct 19, 9:04*pm, Bali <sumeetkb...@gmail.comwrote:
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.
Oct 19 '08 #4
On Oct 19, 2:27*pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:
On Oct 19, 9:04*pm, Bali <sumeetkb...@gmail.comwrote:
Apparently not. If I typehttp://localhost/..../webform2.aspxinIE, 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.
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
Oct 20 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Marcin 'Qrczak' Kowalczyk | last post: by
31 posts views Thread by Chris S. | last post: by
1 post views Thread by tshad | last post: by
2 posts views Thread by Kris | last post: by
21 posts views Thread by John Henry | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.