Whenever I add a CheckboxList control to my page in design view, I'm not seeing the corresponding protected variable that the form designer automatically adds in the .cs file.
Also, I can't find the OnInit method and InitializeComponent methods in my .cs file. I don't think I deleted them. How to restore this page in proper order ? How could have they disappeared?
I'm using the AJAX Extensions/ .Net 2.0 / VS 2005 / developing on XP Professional / IIS on a Windows 2000
If you're using 2.0, you won't see these control declarations any more. These declarations along with your event declartaions are now placed into an automatically generated partial class which are combined together when compiled. Therefore, you should still
be able to reference this CheckBoxList control from your code-behind page, but you simply won't see the control declaration. Here's an article that may shed some light for you:
Are you new to ASP.Net 2.0? 2.0 no longer behaves the way you expect with regards to putting the protected form field variables in the .cs file that you can edit.
Please remember to "mark as answered" posts that have helped you.
Thanks to both for responding. Thanks for that link. I'm new to 2.0 as you can tell.
I forgot to add this to my original question:
Whenever I double click the SelectedIndexChanged event in the properties for this CheckBoxList, the call gets added to the control in the .aspx file but for some reason, it is not creating that empty event handler method in the
.cs part of it. Why is this ? Please forgive me if I'm missing the obvious.
You are using code behind as you have mentioned previously, but still check the markup portion of it to see if it wasn't created in a <script runat="server"> block.
Please remember to "mark as answered" posts that have helped you.
It's not just the checkboxlist; none of the event handling methods for a gridview are created automatically, when I double click. Could it be because of the AJAX extensions? I'm using the ScriptManager and UpdatePanel from the AJAX Extensions and my Checkbox
list is outside these two elements and the gridview is within the UpdatePanel.
I have solved the problem by creating a new page and copying the stuff from the old page, but I am sure there must be an easier way to that.
The problem is whenever i double click any asp control instead of opening an event handler in CS file it opens it in aspx under tag <script> plus all the controls in cs file show error, clearly meaning that both files are out of Sync, Can any one tell how
to get them in Sync again ?
Is it happening for all the pages in your application or only for a single page. If its happening only for a single page, you can take backup of the page/code, delete the page and recreate and see if the newly created page works fine.
Harshad
----------------------------------------------------------
Please mark as answer if the post helped you.
dministrator
Member
13 Points
23 Posts
.cs file not in sync with .aspx
Mar 28, 2007 02:05 PM|LINK
Whenever I add a CheckboxList control to my page in design view, I'm not seeing the corresponding protected variable that the form designer automatically adds in the .cs file.
Also, I can't find the OnInit method and InitializeComponent methods in my .cs file. I don't think I deleted them. How to restore this page in proper order ? How could have they disappeared?
I'm using the AJAX Extensions/ .Net 2.0 / VS 2005 / developing on XP Professional / IIS on a Windows 2000
Thanks all.
ajax ASP.NET 2.0 codebehind Web Forms aspx .net
ecbruck
All-Star
98772 Points
9690 Posts
Moderator
MVP
Re: .cs file not in sync with .aspx
Mar 28, 2007 02:22 PM|LINK
If you're using 2.0, you won't see these control declarations any more. These declarations along with your event declartaions are now placed into an automatically generated partial class which are combined together when compiled. Therefore, you should still be able to reference this CheckBoxList control from your code-behind page, but you simply won't see the control declaration. Here's an article that may shed some light for you:
http://west-wind.com/weblog/posts/3016.aspx
Microsoft MVP - ASP.NET
LSU.Net
Contributor
2479 Points
467 Posts
Re: .cs file not in sync with .aspx
Mar 28, 2007 02:25 PM|LINK
Please remember to "mark as answered" posts that have helped you.
-----
http://lsudotnet.blogspot.com
dministrator
Member
13 Points
23 Posts
Re: .cs file not in sync with .aspx
Mar 28, 2007 02:52 PM|LINK
Thanks to both for responding. Thanks for that link. I'm new to 2.0 as you can tell.
I forgot to add this to my original question:
Whenever I double click the SelectedIndexChanged event in the properties for this CheckBoxList, the call gets added to the control in the .aspx file but for some reason, it is not creating that empty event handler method in the .cs part of it. Why is this ? Please forgive me if I'm missing the obvious.
ecbruck
All-Star
98772 Points
9690 Posts
Moderator
MVP
Re: .cs file not in sync with .aspx
Mar 28, 2007 02:59 PM|LINK
Microsoft MVP - ASP.NET
LSU.Net
Contributor
2479 Points
467 Posts
Re: .cs file not in sync with .aspx
Mar 28, 2007 03:01 PM|LINK
Dministrator,
You are using code behind as you have mentioned previously, but still check the markup portion of it to see if it wasn't created in a <script runat="server"> block.
Please remember to "mark as answered" posts that have helped you.
-----
http://lsudotnet.blogspot.com
dministrator
Member
13 Points
23 Posts
Re: .cs file not in sync with .aspx
Mar 28, 2007 03:14 PM|LINK
It's not just the checkboxlist; none of the event handling methods for a gridview are created automatically, when I double click. Could it be because of the AJAX extensions? I'm using the ScriptManager and UpdatePanel from the AJAX Extensions and my Checkbox list is outside these two elements and the gridview is within the UpdatePanel.
I really do thank you for your time and patience.
Nayyarmas
Member
53 Points
22 Posts
Re: .cs file not in sync with .aspx
Oct 19, 2010 06:27 AM|LINK
I am having the same problem, Any one please ?
Nayyarmas
Member
53 Points
22 Posts
Re: .cs file not in sync with .aspx
Oct 21, 2010 06:24 AM|LINK
I have solved the problem by creating a new page and copying the stuff from the old page, but I am sure there must be an easier way to that.
The problem is whenever i double click any asp control instead of opening an event handler in CS file it opens it in aspx under tag <script> plus all the controls in cs file show error, clearly meaning that both files are out of Sync, Can any one tell how to get them in Sync again ?
Thanks in advance
aspx cs sync
riswadkarhar...
Contributor
2458 Points
560 Posts
Re: .cs file not in sync with .aspx
Oct 21, 2010 06:29 AM|LINK
Hi,
Is it happening for all the pages in your application or only for a single page. If its happening only for a single page, you can take backup of the page/code, delete the page and recreate and see if the newly created page works fine.
----------------------------------------------------------
Please mark as answer if the post helped you.