aspx server controls are not recognized in the code-behind files [Resolved]

Posted by Murugavelmsc under ASP.NET on 7/31/2013 | Points: 10 | Views : 4446 | Status : [Member] | Replies : 15
Hi Experts,

In VS 2010, aspx server controls are not recognized in the code-behind files.

Is there any specific reason.

I have tried the following:

1.I have checked the CodeBehind=""
2.restart the VS 2010 several times


Please help me

Regards,
Murugavel S
murugavel.sadagopan@gmail.com
http://murugavelmsc.blogspot.in/



Responses

Posted by: Kmandapalli on: 7/31/2013 [Member] Silver | Points: 50

Up
0
Down

Resolved
Hi,

Can you please Mark it as Answer...

Regards,
Shree M.

Kavya Shree Mandapalli

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kmandapalli on: 7/31/2013 [Member] Silver | Points: 25

Up
0
Down
Hi,

Check in this way...

4 down vote accepted


There should be two files attached to your .aspx page. One should be a .aspx.designer.cs file, and the other should be the codebehind file, the .aspx.cs file.

If you right click the aspx file in the solution explorer and choose "View Codegen File", it should open the .aspx.designer.cs file for you. The Label should be declared in there.

If not, then the designer hasn't correctly parsed your markup yet. Open the .aspx file in design view, make a small change, revert it and delete it to get the designer to run again

Mark as answer if you are satisfied......

Regards,
Shree M.


Kavya Shree Mandapalli

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Murugavelmsc on: 7/31/2013 [Member] Starter | Points: 25

Up
0
Down
Sorry Shree.
I couldn't find any "View Codegen File" in right click of the solution explorer in Visual Studio 2010.



Regards,
Murugavel S
murugavel.sadagopan@gmail.com
http://murugavelmsc.blogspot.in/

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kmandapalli on: 7/31/2013 [Member] Silver | Points: 25

Up
0
Down
Hi,

Make sure you didn't just copy the entire page from your web site to your web application, but you created a new page.

Make sure your .aspx page has a correct @page directive, something close to:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>

Mark as answer if satisfied.......

Regards,
Shree M.

Kavya Shree Mandapalli

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Murugavelmsc on: 7/31/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,

I have checked everything seems to be fine.

I don't know why its not working.



Regards,
Murugavel S
murugavel.sadagopan@gmail.com
http://murugavelmsc.blogspot.in/

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kmandapalli on: 7/31/2013 [Member] Silver | Points: 25

Up
0
Down
Hi,

Once delete the control and again add a new control and try to access it..
Mean while send me the code so that i can check it out

Mark as answer if satisfied.......

Regards,
Shree M.

Kavya Shree Mandapalli

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kmandapalli on: 7/31/2013 [Member] Silver | Points: 25

Up
0
Down
Hi,

If the button is inside a naming container like a repeater you won't be able to use it like that. Instead, you need to do something like this:

Button myButton = (Button)Container.FindControl("myButton");
myButton.Text = "bye";

Mark as answer if satisfied.....

Regards,
Shree M.

Kavya Shree Mandapalli

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Murugavelmsc on: 7/31/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,

I have attached the code.
 Download source file

Regards,
Murugavel S
murugavel.sadagopan@gmail.com
http://murugavelmsc.blogspot.in/

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Murugavelmsc on: 7/31/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,

In the attached file i have changes CodeFile instead of CodeBehind.

Please change as CodeBehind...

Regards,
Murugavel S
murugavel.sadagopan@gmail.com
http://murugavelmsc.blogspot.in/

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kmandapalli on: 7/31/2013 [Member] Silver | Points: 25

Up
0
Down
Hi,

You create a new web application and copy all the code except the page directive and access the server controls.
I think it will work because i think there is a mistake in your page directive

Regards,
Shree M.

Kavya Shree Mandapalli

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kmandapalli on: 7/31/2013 [Member] Silver | Points: 25

Up
0
Down
Hi,

Its not Codefile and its CodeBehind..
So, add new project and under that page directive write your code.
It will work...

Regards,
Shree M.

Kavya Shree Mandapalli

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Murugavelmsc on: 7/31/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,

Whenever I create a new form in the new project page directive has CodeFile instead of CodeBehind.

But i have change the CodeBehind as CodeFile its working fine for me.


What to do.



Regards,
Murugavel S
murugavel.sadagopan@gmail.com
http://murugavelmsc.blogspot.in/

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kmandapalli on: 7/31/2013 [Member] Silver | Points: 25

Up
0
Down
Hi,

So, Now you can access your server controls in the .cs page .
Issue got solved naa....

Plz Mark as answer if satisfied.......

Regards,
Shree M.

Kavya Shree Mandapalli

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Murugavelmsc on: 7/31/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,

Why Page Directive has attribute as CodeFile instaed of CodeBehind when create a new form?

Default page directive have CodeBehind as attribute rite




Regards,
Murugavel S
murugavel.sadagopan@gmail.com
http://murugavelmsc.blogspot.in/

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kmandapalli on: 7/31/2013 [Member] Silver | Points: 25

Up
0
Down
Hi,

Dont know because for me its coming CodeBehind as default.
May be any change...

Mark as Answer if satisfied......

Regards,
Shree M.

Kavya Shree Mandapalli

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response