473,461 Members | 1,102 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to convert 1.1 code-behind page to 2.0 format?

Hello,

I have installed the 2.0 framework, and am looking at converting some of
my 1.1 pages to use partial classes. I don't (yet) have VS2005, so I'm
doing this by hand, but am having problems.

I have a simple page that I made in the beta2 version of VWD. The code
behind looks like...

using System;
using System.Web.UI;

public partial class _Default : Page {
protected void Page_Load(object sender, EventArgs e) {
// do stuff here
}
}

From this, I assumed that all I needed to do to my existing code-behind
files was to change the class definition to be partial, and remove the
large list of lines like...

protected Literal litTest;
// etc

from the class definition. I did this, but the compiler complained that
litTest did not exist in the current context. If I put back the above
line, it worked.

The code-behind file that VWD generated didn't have the lines in
declaring each control in the code-behind, and it worked fine. What do I
need to do to get my file to work like that? I looked in the folder
where the files live, and couldn't see any other file relating to this
page. I seem to remember that 2.0 uses a third file, which contains
extra info. Is that what I'm missing? I couldn't see one for the page
VWD created, and I could move this page to another site and it worked
fine.

Thanks for any help.

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #1
7 1731
Anyone have an answer for this? Surely it must be a very common
question. Am I the only person trying to convert 1.1 pages to work with
2.0?
Hello,

I have installed the 2.0 framework, and am looking at converting some
of my 1.1 pages to use partial classes. I don't (yet) have VS2005, so
I'm doing this by hand, but am having problems.

I have a simple page that I made in the beta2 version of VWD. The code
behind looks like...

using System;
using System.Web.UI;

public partial class _Default : Page {
protected void Page_Load(object sender, EventArgs e) {
// do stuff here
}
}

From this, I assumed that all I needed to do to my existing code-behind
files was to change the class definition to be partial, and remove the
large list of lines like...

protected Literal litTest;
// etc

from the class definition. I did this, but the compiler complained that
litTest did not exist in the current context. If I put back the above
line, it worked.

The code-behind file that VWD generated didn't have the lines in
declaring each control in the code-behind, and it worked fine. What do
I need to do to get my file to work like that? I looked in the folder
where the files live, and couldn't see any other file relating to this
page. I seem to remember that 2.0 uses a third file, which contains
extra info. Is that what I'm missing? I couldn't see one for the page
VWD created, and I could move this page to another site and it worked fine.

Thanks for any help.


--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #2
Try :

using System;
using System.Web.UI;
// etc...

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// do stuff here
}

}

re:
protected Literal litTest;
// etc

That *is* needed...

See :
http://msdn.microsoft.com/asp.net/be...ta2update.aspx
and
http://msdn.microsoft.com/asp.net/re...uesasp_net.asp
and
http://msdn.microsoft.com/asp.net/re...e/default.aspx

for other critical changes going from 1.1 to 2.0

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:mE**************@nospamthankyou.spam...
Anyone have an answer for this? Surely it must be a very common question. Am I the only
person trying to convert 1.1 pages to work with 2.0?
Hello,

I have installed the 2.0 framework, and am looking at converting some of my 1.1 pages to
use partial classes. I don't (yet) have VS2005, so I'm doing this by hand, but am having
problems.

I have a simple page that I made in the beta2 version of VWD. The code behind looks
like...

using System;
using System.Web.UI;

public partial class _Default : Page {
protected void Page_Load(object sender, EventArgs e) {
// do stuff here
}
}

From this, I assumed that all I needed to do to my existing code-behind files was to
change the class definition to be partial, and remove the large list of lines like...

protected Literal litTest;
// etc

from the class definition. I did this, but the compiler complained that litTest did not
exist in the current context. If I put back the above line, it worked.

The code-behind file that VWD generated didn't have the lines in declaring each control
in the code-behind, and it worked fine. What do I need to do to get my file to work like
that? I looked in the folder where the files live, and couldn't see any other file
relating to this page. I seem to remember that 2.0 uses a third file, which contains
extra info. Is that what I'm missing? I couldn't see one for the page VWD created, and I
could move this page to another site and it worked fine.

Thanks for any help.


--
Alan Silver
(anything added below this line is nothing to do with me)

Nov 19 '05 #3
Juan,

Thanks for the reply, but I'm still not clear!!

As far as the first bit of your post...
Try :

using System;
using System.Web.UI;
// etc...

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// do stuff here
}

}
I'm not sure what you're gaining by adding System.Web.UI.Page instead of
just Page, as the System.Web.UI namespace is already referenced at the
top of the file. Why would this make any difference?

More to the point however...
re:
protected Literal litTest;
// etc

That *is* needed...
Well, if you reread my original post, you will see that it seems it
isn't!! VWD created an .aspx and a code-behind for me, and the
"protected Literal litTest;" lines were *not* included. I copied these
two files to another web server entirely, one that has never seen VWD,
and the page ran fine.

Also...
See : <snip links>for other critical changes going from 1.1 to 2.0
I've seen most of that before, but thanks for pointing it out anyway.

Whilst looking through those links, I came across
http://msdn.microsoft.com/asp.net/re...de/default.asp
x?pull=/library/en-us/dnvs05/html/migratefromaspnetto2.asp, which shows
(just below figure 3) a new code-behind file, that does *not* have the
"protected..." lines in it.

Moreover, the text below the sample code explicitly states...

"The code-behind file has automatic access to any controls added to the
ASP.NET page"

.... which I read to support the fact that the code-behind file shown
doesn't included the references to the controls.

Hopefully you see why I didn't understand your reply. The code-behind
file that VWD generated didn't include the references, the MSDN article
seems to say that that they are not needed, but when I tried it on an
existing 1.1 file of mine, the compiler complained when I removed the
references. You say that they *are* needed. I'm confused ;-)

I would appreciate any explanation you have.

Thanks for the reply.
Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:mE**************@nospamthankyou.spam...
Anyone have an answer for this? Surely it must be a very common
question. Am I the only
person trying to convert 1.1 pages to work with 2.0?
Hello,

I have installed the 2.0 framework, and am looking at converting some
of my 1.1 pages to
use partial classes. I don't (yet) have VS2005, so I'm doing this by
hand, but am having
problems.

I have a simple page that I made in the beta2 version of VWD. The
code behind looks
like...

using System;
using System.Web.UI;

public partial class _Default : Page {
protected void Page_Load(object sender, EventArgs e) {
// do stuff here
}
}

From this, I assumed that all I needed to do to my existing
code-behind files was to
change the class definition to be partial, and remove the large list
of lines like...

protected Literal litTest;
// etc

from the class definition. I did this, but the compiler complained
that litTest did not
exist in the current context. If I put back the above line, it worked.

The code-behind file that VWD generated didn't have the lines in
declaring each control
in the code-behind, and it worked fine. What do I need to do to get
my file to work like
that? I looked in the folder where the files live, and couldn't see
any other file
relating to this page. I seem to remember that 2.0 uses a third file,
which contains
extra info. Is that what I'm missing? I couldn't see one for the page
VWD created, and I
could move this page to another site and it worked fine.

Thanks for any help.


--
Alan Silver
(anything added below this line is nothing to do with me)



--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #4
re:
I would appreciate any explanation you have.
I short-circuited ?

It happens every so often ( even to the best among us... )

;-)

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:z3**************@nospamthankyou.spam... Juan,

Thanks for the reply, but I'm still not clear!!

As far as the first bit of your post...
Try :

using System;
using System.Web.UI;
// etc...

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// do stuff here
}

}


I'm not sure what you're gaining by adding System.Web.UI.Page instead of just Page, as
the System.Web.UI namespace is already referenced at the top of the file. Why would this
make any difference?

More to the point however...
re:
protected Literal litTest;
// etc

That *is* needed...


Well, if you reread my original post, you will see that it seems it isn't!! VWD created
an .aspx and a code-behind for me, and the "protected Literal litTest;" lines were *not*
included. I copied these two files to another web server entirely, one that has never
seen VWD, and the page ran fine.

Also...
See :

<snip links>
for other critical changes going from 1.1 to 2.0


I've seen most of that before, but thanks for pointing it out anyway.

Whilst looking through those links, I came across
http://msdn.microsoft.com/asp.net/re...de/default.asp
x?pull=/library/en-us/dnvs05/html/migratefromaspnetto2.asp, which shows (just below
figure 3) a new code-behind file, that does *not* have the "protected..." lines in it.

Moreover, the text below the sample code explicitly states...

"The code-behind file has automatic access to any controls added to the ASP.NET page"

... which I read to support the fact that the code-behind file shown doesn't included
the references to the controls.

Hopefully you see why I didn't understand your reply. The code-behind file that VWD
generated didn't include the references, the MSDN article seems to say that that they
are not needed, but when I tried it on an existing 1.1 file of mine, the compiler
complained when I removed the references. You say that they *are* needed. I'm confused
;-)

I would appreciate any explanation you have.

Thanks for the reply.
Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:mE**************@nospamthankyou.spam...
Anyone have an answer for this? Surely it must be a very common question. Am I the
only
person trying to convert 1.1 pages to work with 2.0?

Hello,

I have installed the 2.0 framework, and am looking at converting some of my 1.1 pages
to
use partial classes. I don't (yet) have VS2005, so I'm doing this by hand, but am
having
problems.

I have a simple page that I made in the beta2 version of VWD. The code behind looks
like...

using System;
using System.Web.UI;

public partial class _Default : Page {
protected void Page_Load(object sender, EventArgs e) {
// do stuff here
}
}

From this, I assumed that all I needed to do to my existing code-behind files was to
change the class definition to be partial, and remove the large list of lines like...

protected Literal litTest;
// etc

from the class definition. I did this, but the compiler complained that litTest did
not
exist in the current context. If I put back the above line, it worked.

The code-behind file that VWD generated didn't have the lines in declaring each
control
in the code-behind, and it worked fine. What do I need to do to get my file to work
like
that? I looked in the folder where the files live, and couldn't see any other file
relating to this page. I seem to remember that 2.0 uses a third file, which contains
extra info. Is that what I'm missing? I couldn't see one for the page VWD created, and
I
could move this page to another site and it worked fine.

Thanks for any help.
--
Alan Silver
(anything added below this line is nothing to do with me)



--
Alan Silver
(anything added below this line is nothing to do with me)

Nov 19 '05 #5
>re:
I would appreciate any explanation you have.
I short-circuited ?

It happens every so often ( even to the best among us... )

;-)


Glad to know it's not just me!!

OK, so if we agree that the control references aren't needed, are you
able to explain why I couldn't do this to an 1.1 existing page?

I changed the class declaration to be partial, and removed the list of
control declarations. That was all I could see that differentiated
between the 1.1 file I had and the 2.0 file VWD created. Oh, I also
changed the page directive of the .aspx file. When I tried to load it, I
got an exception saying a control (the first one referenced in the code)
didn't exist.

Any ideas? Thanks again
Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:z3**************@nospamthankyou.spam...
Juan,

Thanks for the reply, but I'm still not clear!!

As far as the first bit of your post...
Try :

using System;
using System.Web.UI;
// etc...

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// do stuff here
}

}


I'm not sure what you're gaining by adding System.Web.UI.Page instead
of just Page, as
the System.Web.UI namespace is already referenced at the top of the
file. Why would this
make any difference?

More to the point however...
re:
protected Literal litTest;
// etc

That *is* needed...


Well, if you reread my original post, you will see that it seems it
isn't!! VWD created
an .aspx and a code-behind for me, and the "protected Literal
litTest;" lines were *not*
included. I copied these two files to another web server entirely,
one that has never
seen VWD, and the page ran fine.

Also...
See :

<snip links>
for other critical changes going from 1.1 to 2.0


I've seen most of that before, but thanks for pointing it out anyway.

Whilst looking through those links, I came across
http://msdn.microsoft.com/asp.net/re...de/default.asp
x?pull=/library/en-us/dnvs05/html/migratefromaspnetto2.asp, which
shows (just below
figure 3) a new code-behind file, that does *not* have the
"protected..." lines in it.

Moreover, the text below the sample code explicitly states...

"The code-behind file has automatic access to any controls added to
the ASP.NET page"

... which I read to support the fact that the code-behind file shown
doesn't included
the references to the controls.

Hopefully you see why I didn't understand your reply. The code-behind
file that VWD
generated didn't include the references, the MSDN article seems to
say that that they
are not needed, but when I tried it on an existing 1.1 file of mine,
the compiler
complained when I removed the references. You say that they *are*
needed. I'm confused
;-)

I would appreciate any explanation you have.

Thanks for the reply.
Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:mE**************@nospamthankyou.spam...
Anyone have an answer for this? Surely it must be a very common
question. Am I the
only
person trying to convert 1.1 pages to work with 2.0?

>Hello,
>
>I have installed the 2.0 framework, and am looking at converting
>some of my 1.1 pages
>to
>use partial classes. I don't (yet) have VS2005, so I'm doing this
>hand, but am
>having
>problems.
>
>I have a simple page that I made in the beta2 version of VWD. The
>code behind looks
>like...
>
>using System;
>using System.Web.UI;
>
>public partial class _Default : Page {
> protected void Page_Load(object sender, EventArgs e) {
> // do stuff here
> }
>}
>
>From this, I assumed that all I needed to do to my existing
>code-behind files was to
>change the class definition to be partial, and remove the large
>list of lines like...
>
>protected Literal litTest;
>// etc
>
>from the class definition. I did this, but the compiler complained
>that litTest did
>not
>exist in the current context. If I put back the above line, it worked.
>
>The code-behind file that VWD generated didn't have the lines in
>declaring each
>control
>in the code-behind, and it worked fine. What do I need to do to get
>my file to work
>like
>that? I looked in the folder where the files live, and couldn't see
>other file
>relating to this page. I seem to remember that 2.0 uses a third
>file, which contains
>extra info. Is that what I'm missing? I couldn't see one for the
>page VWD created, and
>I
>could move this page to another site and it worked fine.
>
>Thanks for any help.
>

--
Alan Silver
(anything added below this line is nothing to do with me)


--
Alan Silver
(anything added below this line is nothing to do with me)



--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #6
The protected control references are not needed in the codebehind page
as the aspx file and the codebehind file sine asp.net combines these 2
classes into 1 class. This is what partial class brings to the table in
..NET 2.0.

In the @page directive there will be an attribute called Inherits which
sholud point to your _Default class and another attribute called
CodeFile which VWD usues to link both files in the designer.

As far as your error goes. It would be good to see what your aspx file
looks like since your codebehind file seems to be ok.

Nov 19 '05 #7
<Plays theme from Twilight Zone>

Well, I don't know what I did differently now from the other day, but I
just tried it again and it worked fine!!

I wonder if I didn't change the Src attribute of the page directive to
CodeFile? Rereading my original post, I didn't mention doing that, so it
could be I missed that change.

Anyway, all seems to be working now. Thanks very much for your reply.
The protected control references are not needed in the codebehind page
as the aspx file and the codebehind file sine asp.net combines these 2
classes into 1 class. This is what partial class brings to the table in
.NET 2.0.

In the @page directive there will be an attribute called Inherits which
sholud point to your _Default class and another attribute called
CodeFile which VWD usues to link both files in the designer.

As far as your error goes. It would be good to see what your aspx file
looks like since your codebehind file seems to be ok.


--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is...
5
by: Omey Samaroo | last post by:
Dear Access Gurus, I am tasked with converting an Access 97 Database to A2K. I created Macros, switchboards and used the full feature of buttons on forms. The A97 is also split (FE and BE). Are...
25
by: Charles Law | last post by:
I thought this was going to be straight forward, given the wealth of conversion functions in .NET, but it is proving more convoluted than imagined. Given the following <code> Dim ba(1) As...
7
by: patang | last post by:
I want to convert amount to words. Is there any funciton available? Example: $230.30 Two Hundred Thirty Dollars and 30/100
6
by: patang | last post by:
Could someone please tell me where am I supposed to put this code. Actually my project has two forms. I created a new module and have put the following code sent by someone. All the function...
4
by: Edwin Knoppert | last post by:
In my code i use the text from a textbox and convert it to a double value. I was using Convert.ToDouble() but i'm used to convert comma to dot. This way i can assure the text is correct. However...
7
by: groups | last post by:
This is my first foray into writing a generic method and maybe I've bitten off more than I can chew. My intent is to have a generic method that accepts a value name and that value will be...
10
by: =?Utf-8?B?Um95?= | last post by:
What is the way to have best performance to copy a byte to a value such as long? I use BitConverter.ToInt64(binary, offset) But the performace is not good enough. I need to have the best...
19
by: tshad | last post by:
I have a value in my sql table set to tinyint (can't set to bit). I am trying to move it into a boolean field in my program and have tried: isTrue = (int)dbReader and isTrue =...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.