E
es330td
Environment: Windows 2003, SQL 2K5, VS2K5 (BTW...I own copies of
these. I am not in a position to upgrade to 2008 or 2010 versions of
any of the above.)
(Note: I am not new to web development or programming. I wrote some
pretty extensive apps in VB.Net and Classic ASP several years ago. My
employer is a C# shop so I decided to use this as an opportunity to
jump to C# from VB.)
After two years out of IT I am trying to learn C# for an app I want to
write. I downloaded a package of examples from MSDN entitled "101 C#
Samples." When I try to open a .csproj it tells me that it needs to
be converted so I am assuming it was created for VS2003. When I try
to run the sample web apps I get errors along the lines of "The type
'Main' already contains a definition for 'btnSave'." It appears to me
that it is doing this because the following lines are in the .aspx.cs
file
public partial class Main: System.Web.UI.Page
{
protected Button btnSave;
while the following line exists in the .aspx file
<asp:Button id="btnSave" Text="Save Changes"
To my uneducated brain, I wouldn't think there shouldn't be a conflict
between the web page and the codebehind page, but it appears that this
is in fact the case. When I was coding in VS2003 and VB.Net this was
not a problem; iirc I would code my objects with the same names to
keep them more clearly connected for readability. I was able to get
one app to run by changing the name of one object to distinguish them
and then work through the code changing the references to the renamed
object until it worked. While I am okay with doing this, and naming
objects different from their codebehind objects, I can't help but
wonder if there is something about which I don't know that would let
me leave these named as they are.
Thanks in advance for your input on this.
these. I am not in a position to upgrade to 2008 or 2010 versions of
any of the above.)
(Note: I am not new to web development or programming. I wrote some
pretty extensive apps in VB.Net and Classic ASP several years ago. My
employer is a C# shop so I decided to use this as an opportunity to
jump to C# from VB.)
After two years out of IT I am trying to learn C# for an app I want to
write. I downloaded a package of examples from MSDN entitled "101 C#
Samples." When I try to open a .csproj it tells me that it needs to
be converted so I am assuming it was created for VS2003. When I try
to run the sample web apps I get errors along the lines of "The type
'Main' already contains a definition for 'btnSave'." It appears to me
that it is doing this because the following lines are in the .aspx.cs
file
public partial class Main: System.Web.UI.Page
{
protected Button btnSave;
while the following line exists in the .aspx file
<asp:Button id="btnSave" Text="Save Changes"
To my uneducated brain, I wouldn't think there shouldn't be a conflict
between the web page and the codebehind page, but it appears that this
is in fact the case. When I was coding in VS2003 and VB.Net this was
not a problem; iirc I would code my objects with the same names to
keep them more clearly connected for readability. I was able to get
one app to run by changing the name of one object to distinguish them
and then work through the code changing the references to the renamed
object until it worked. While I am okay with doing this, and naming
objects different from their codebehind objects, I can't help but
wonder if there is something about which I don't know that would let
me leave these named as they are.
Thanks in advance for your input on this.