473,241 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

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 1723
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...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...

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.