473,545 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ 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(objec t 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 1739
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(objec t 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.P age
{
protected void Page_Load(objec t 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*********@no spam.thanx> wrote in message
news:mE******** ******@nospamth ankyou.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(objec t 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.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
// do stuff here
}

}
I'm not sure what you're gaining by adding System.Web.UI.P age 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/migratefromaspn etto2.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.CO M : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
============== =============== =========
"Alan Silver" <al*********@no spam.thanx> wrote in message
news:mE******* *******@nospamt hankyou.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(objec t 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*********@no spam.thanx> wrote in message
news:z3******** ******@nospamth ankyou.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.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
// do stuff here
}

}


I'm not sure what you're gaining by adding System.Web.UI.P age 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/migratefromaspn etto2.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.C OM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
============= =============== ==========
"Alan Silver" <al*********@no spam.thanx> wrote in message
news:mE****** ********@nospam thankyou.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(objec t 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.CO M : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
============== =============== =========
"Alan Silver" <al*********@no spam.thanx> wrote in message
news:z3******* *******@nospamt hankyou.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.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
// do stuff here
}

}


I'm not sure what you're gaining by adding System.Web.UI.P age 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/migratefromaspn etto2.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.CO M : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
============ =============== ===========
"Alan Silver" <al*********@no spam.thanx> wrote in message
news:mE***** *********@nospa mthankyou.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(objec t 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...
>
>protecte d 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
>declarin g 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
3608
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 of the type the object is instantiated with. In my test program I have Option<std::string> and Option<long>. Here's the code for OptionBase and...
5
1626
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 there any suggestions that I should keep in mind while attempting to do this task ? What can I expect ? Thanks
25
7232
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 Byte Dim b As Byte
7
29177
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
1407
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 declaration statments (first lines) e.g. Public Function ConvertCurrencyToEnglish(ByVal MyNumber As Double) As String Private Function...
4
4508
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 it seems this convert is determined by the local settings and comma is indeed used as decimal separator. Is there another way to convert a dotted...
7
16630
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 returned from the source. My first attempt was as follows; (please ignore that error handling is not present in this example) public T...
10
4868
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 performance in my case.
19
14756
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 = Convert.ToBoolean((int)dbReader)
0
10720
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 inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not...
0
7473
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7661
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7815
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7433
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7763
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5976
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5340
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4949
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
712
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.