Pointing at code behinh in User Control-C#

A

aarepasky

I have built a user control. When a button is clicked I want it to go
to a subroutine in the code behind. But it wants me to put it in the
asp code as a script. So how do I point to the code in the other file.
I have tried things and all I get is other errors.

I want to fix this error, but it has to find it in the code behind.

Error 4 'ASP.WebUserControl' does not contain a definition for
'Button1_Click' C:\Documents and Settings\kevinrep\My
Documents\Visual Studio 2005\WebSites\NewProp\Companies.ascx 31

This is probably something simple, but I just do not know what to do.

Thanks,
riprip
 
M

Mark Fitzpatrick

Are you referencing the file with the new CodeFile attribute of the Page
Directive? Also, make sure that the class in the codefile is declared as a
partial class.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 
A

aarepasky

Mark,

I figured it out by creating a new user control. The wizard had on
option to create a code behind file. So I recreated the user control
by copying everything in the new user control and copying the code I
needed to the new user control code file. Then I excluded the old user
control from the project so that I could rename the new control to the
original name. Then I had to clean up the renaming in some of the
files to the new name. It worked.

The reason I did all that is that I did not know how to create the C#
code fine in the project. I knew I had to use the CodeFile attribute
and Inherits attribute, but I did not know what to put in them. Now I
know.

Now I have another problem so I guess I will have to make a new post if
I can not figure it out.

Thanks for getting back to me.

Riprip
 

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