473,398 Members | 2,120 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,398 software developers and data experts.

SRC instead of CodeBehind

A.M
Hi,

Using VS.NET 2003, If i use SRC page attribute instead of CodeBehind, do i
still have intelisence and generally IDE support for that?

Thanks,
Ali
Nov 18 '05 #1
12 1728
Hi Richard,

Thank you for using Microsoft Newsgroup Service. As for the question you
mentioned, the "SRC" attribute and "CodeBehind" attribute of the <%@Page
...> Direction will specify different compile mode for the ASP.NET web
page. Also, that will cause quite different effect when designing the
page's binded class at design-time. Here is the description in the MSDN:

"CodeBehind" attribute:
Specifies the name of the compiled file that contains the class associated
with the page. This attribute is used by the Visual Studio .NET Web Forms
designer. It tells the designer where to find the page class so that the
designer can create an instance of it for you to work with at design time.
For example, if you create a Web Forms page in Visual Studio called
WebForm1, the designer will assign the Codebehind attribute the value of
WebForm1.aspx.vb, for Visual Basic, or WebForm1.aspx.cs, for C#. This
attribute is not used at run time.

"SRC" attribute:
Specifies the source file name of the code-behind class to dynamically
compile when the page is requested. You can choose to include programming
logic for your page either in a code-behind class or in a code declaration
block in the .aspx file.

Note RAD designers, such as Visual Studio .NET, do not use this
attribute. Instead, they precompile code-behind classes and then use the
Inherits attribute.

So if use "SRC" attribute, the IDE Designer won't get any of the page's
binded class info until the page is requested at runtime. Thus, when
designing the page class source, it will lose the intelisence and
generally IDE support for it.
Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #2
A.M

Thanks Steven for help.

I underestand the best way to have IDE support is using code behind.

We like to use SRC because we can use notepad to change the codes
whenever/wherever we want and ASP.NET will take care of compilation; however
we also would like to have IDE support during the actual development.

To achive what we need can i develop my web application with CodeBehind page
attribute (to have IDE support during development) and right before
deployment change all CodeBehind page attribute to SRC ?

To re-phrase my question: If i develop my web application using CodeBehind
page attribute, can i change "CodeBehinf" to "SRC" and my pages get compiled
by ASP.NET? If the answer is no, then how can I convert a page from
"CodeBehind" model to "SRC" model ?

Thanks again,
Ali


"MSFT" <v-******@online.microsoft.com> wrote in message
news:dS**************@cpmsftngxa07.phx.gbl...
Hi Richard,

Thank you for using Microsoft Newsgroup Service. As for the question you
mentioned, the "SRC" attribute and "CodeBehind" attribute of the <%@Page
..> Direction will specify different compile mode for the ASP.NET web
page. Also, that will cause quite different effect when designing the
page's binded class at design-time. Here is the description in the MSDN:

"CodeBehind" attribute:
Specifies the name of the compiled file that contains the class associated
with the page. This attribute is used by the Visual Studio .NET Web Forms
designer. It tells the designer where to find the page class so that the
designer can create an instance of it for you to work with at design time.
For example, if you create a Web Forms page in Visual Studio called
WebForm1, the designer will assign the Codebehind attribute the value of
WebForm1.aspx.vb, for Visual Basic, or WebForm1.aspx.cs, for C#. This
attribute is not used at run time.

"SRC" attribute:
Specifies the source file name of the code-behind class to dynamically
compile when the page is requested. You can choose to include programming
logic for your page either in a code-behind class or in a code declaration
block in the .aspx file.

Note RAD designers, such as Visual Studio .NET, do not use this
attribute. Instead, they precompile code-behind classes and then use the
Inherits attribute.

So if use "SRC" attribute, the IDE Designer won't get any of the page's
binded class info until the page is requested at runtime. Thus, when
designing the page class source, it will lose the intelisence and
generally IDE support for it.
Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #3
You don't want to CHANGE "CodeBehind" to "Src" - you want to use BOTH.
"CodeBehind" tells the VS.Net IDE where to find the CodeBehind file at
design-time. "Src" tells your ASP.Net Page Template where to find it at
run-time.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"A.M" <IH*******@sapm123.com> wrote in message
news:O2**************@TK2MSFTNGP09.phx.gbl...

Thanks Steven for help.

I underestand the best way to have IDE support is using code behind.

We like to use SRC because we can use notepad to change the codes
whenever/wherever we want and ASP.NET will take care of compilation; however we also would like to have IDE support during the actual development.

To achive what we need can i develop my web application with CodeBehind page attribute (to have IDE support during development) and right before
deployment change all CodeBehind page attribute to SRC ?

To re-phrase my question: If i develop my web application using CodeBehind
page attribute, can i change "CodeBehinf" to "SRC" and my pages get compiled by ASP.NET? If the answer is no, then how can I convert a page from
"CodeBehind" model to "SRC" model ?

Thanks again,
Ali


"MSFT" <v-******@online.microsoft.com> wrote in message
news:dS**************@cpmsftngxa07.phx.gbl...
Hi Richard,

Thank you for using Microsoft Newsgroup Service. As for the question you
mentioned, the "SRC" attribute and "CodeBehind" attribute of the <%@Page
..> Direction will specify different compile mode for the ASP.NET web
page. Also, that will cause quite different effect when designing the
page's binded class at design-time. Here is the description in the MSDN:

"CodeBehind" attribute:
Specifies the name of the compiled file that contains the class associated with the page. This attribute is used by the Visual Studio .NET Web Forms designer. It tells the designer where to find the page class so that the
designer can create an instance of it for you to work with at design time. For example, if you create a Web Forms page in Visual Studio called
WebForm1, the designer will assign the Codebehind attribute the value of
WebForm1.aspx.vb, for Visual Basic, or WebForm1.aspx.cs, for C#. This
attribute is not used at run time.

"SRC" attribute:
Specifies the source file name of the code-behind class to dynamically
compile when the page is requested. You can choose to include programming logic for your page either in a code-behind class or in a code declaration block in the .aspx file.

Note RAD designers, such as Visual Studio .NET, do not use this
attribute. Instead, they precompile code-behind classes and then use the
Inherits attribute.

So if use "SRC" attribute, the IDE Designer won't get any of the page's
binded class info until the page is requested at runtime. Thus, when
designing the page class source, it will lose the intelisence and
generally IDE support for it.
Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Nov 18 '05 #4
I am curious. I have tried using both but I get runtime errors for ambiguous
names. Am I doing something wrong?
Mike

"Kevin Spencer" <ke***@takempis.com> wrote in message
news:Oi**************@tk2msftngp13.phx.gbl...
You don't want to CHANGE "CodeBehind" to "Src" - you want to use BOTH.
"CodeBehind" tells the VS.Net IDE where to find the CodeBehind file at
design-time. "Src" tells your ASP.Net Page Template where to find it at
run-time.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"A.M" <IH*******@sapm123.com> wrote in message
news:O2**************@TK2MSFTNGP09.phx.gbl...

Thanks Steven for help.

I underestand the best way to have IDE support is using code behind.

We like to use SRC because we can use notepad to change the codes
whenever/wherever we want and ASP.NET will take care of compilation;

however
we also would like to have IDE support during the actual development.

To achive what we need can i develop my web application with CodeBehind

page
attribute (to have IDE support during development) and right before
deployment change all CodeBehind page attribute to SRC ?

To re-phrase my question: If i develop my web application using CodeBehind
page attribute, can i change "CodeBehinf" to "SRC" and my pages get

compiled
by ASP.NET? If the answer is no, then how can I convert a page from
"CodeBehind" model to "SRC" model ?

Thanks again,
Ali


"MSFT" <v-******@online.microsoft.com> wrote in message
news:dS**************@cpmsftngxa07.phx.gbl...
Hi Richard,

Thank you for using Microsoft Newsgroup Service. As for the question you mentioned, the "SRC" attribute and "CodeBehind" attribute of the <%@Page ..> Direction will specify different compile mode for the ASP.NET web
page. Also, that will cause quite different effect when designing the
page's binded class at design-time. Here is the description in the MSDN:
"CodeBehind" attribute:
Specifies the name of the compiled file that contains the class

associated with the page. This attribute is used by the Visual Studio .NET Web Forms designer. It tells the designer where to find the page class so that the designer can create an instance of it for you to work with at design time. For example, if you create a Web Forms page in Visual Studio called
WebForm1, the designer will assign the Codebehind attribute the value of WebForm1.aspx.vb, for Visual Basic, or WebForm1.aspx.cs, for C#. This
attribute is not used at run time.

"SRC" attribute:
Specifies the source file name of the code-behind class to dynamically
compile when the page is requested. You can choose to include programming logic for your page either in a code-behind class or in a code declaration block in the .aspx file.

Note RAD designers, such as Visual Studio .NET, do not use this
attribute. Instead, they precompile code-behind classes and then use the Inherits attribute.

So if use "SRC" attribute, the IDE Designer won't get any of the page's binded class info until the page is requested at runtime. Thus, when
designing the page class source, it will lose the intelisence and
generally IDE support for it.
Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



Nov 18 '05 #5
A.M

I didn't know that i can have both. If what you are saying is possible then
that would be greate, so i can develop/debug in VS.NET and after deployment
(both .aspx and .aspx.vb files and no dll files) i can edit .aspx.vb files
with notepad upon any intsant cahnge requirements.

I tried having CodeBehind and SRC both together, it didn't worked. am i
missing something ?

Thanks for help,
Ali

"Kevin Spencer" <ke***@takempis.com> wrote in message
news:Oi**************@tk2msftngp13.phx.gbl...
You don't want to CHANGE "CodeBehind" to "Src" - you want to use BOTH.
"CodeBehind" tells the VS.Net IDE where to find the CodeBehind file at
design-time. "Src" tells your ASP.Net Page Template where to find it at
run-time.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"A.M" <IH*******@sapm123.com> wrote in message
news:O2**************@TK2MSFTNGP09.phx.gbl...

Thanks Steven for help.

I underestand the best way to have IDE support is using code behind.

We like to use SRC because we can use notepad to change the codes
whenever/wherever we want and ASP.NET will take care of compilation;

however
we also would like to have IDE support during the actual development.

To achive what we need can i develop my web application with CodeBehind

page
attribute (to have IDE support during development) and right before
deployment change all CodeBehind page attribute to SRC ?

To re-phrase my question: If i develop my web application using CodeBehind
page attribute, can i change "CodeBehinf" to "SRC" and my pages get

compiled
by ASP.NET? If the answer is no, then how can I convert a page from
"CodeBehind" model to "SRC" model ?

Thanks again,
Ali


"MSFT" <v-******@online.microsoft.com> wrote in message
news:dS**************@cpmsftngxa07.phx.gbl...
Hi Richard,

Thank you for using Microsoft Newsgroup Service. As for the question you mentioned, the "SRC" attribute and "CodeBehind" attribute of the <%@Page ..> Direction will specify different compile mode for the ASP.NET web
page. Also, that will cause quite different effect when designing the
page's binded class at design-time. Here is the description in the MSDN:
"CodeBehind" attribute:
Specifies the name of the compiled file that contains the class

associated with the page. This attribute is used by the Visual Studio .NET Web Forms designer. It tells the designer where to find the page class so that the designer can create an instance of it for you to work with at design time. For example, if you create a Web Forms page in Visual Studio called
WebForm1, the designer will assign the Codebehind attribute the value of WebForm1.aspx.vb, for Visual Basic, or WebForm1.aspx.cs, for C#. This
attribute is not used at run time.

"SRC" attribute:
Specifies the source file name of the code-behind class to dynamically
compile when the page is requested. You can choose to include programming logic for your page either in a code-behind class or in a code declaration block in the .aspx file.

Note RAD designers, such as Visual Studio .NET, do not use this
attribute. Instead, they precompile code-behind classes and then use the Inherits attribute.

So if use "SRC" attribute, the IDE Designer won't get any of the page's binded class info until the page is requested at runtime. Thus, when
designing the page class source, it will lose the intelisence and
generally IDE support for it.
Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



Nov 18 '05 #6
A.M
I am having same problem too.

"vMike" <Mi************@nospam.gewarren.com.delete> wrote in message
news:br**********@ngspool-d02.news.aol.com...
I am curious. I have tried using both but I get runtime errors for ambiguous names. Am I doing something wrong?
Mike

"Kevin Spencer" <ke***@takempis.com> wrote in message
news:Oi**************@tk2msftngp13.phx.gbl...
You don't want to CHANGE "CodeBehind" to "Src" - you want to use BOTH.
"CodeBehind" tells the VS.Net IDE where to find the CodeBehind file at
design-time. "Src" tells your ASP.Net Page Template where to find it at
run-time.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"A.M" <IH*******@sapm123.com> wrote in message
news:O2**************@TK2MSFTNGP09.phx.gbl...

Thanks Steven for help.

I underestand the best way to have IDE support is using code behind.

We like to use SRC because we can use notepad to change the codes
whenever/wherever we want and ASP.NET will take care of compilation; however
we also would like to have IDE support during the actual development.

To achive what we need can i develop my web application with CodeBehind
page
attribute (to have IDE support during development) and right before
deployment change all CodeBehind page attribute to SRC ?

To re-phrase my question: If i develop my web application using CodeBehind page attribute, can i change "CodeBehinf" to "SRC" and my pages get

compiled
by ASP.NET? If the answer is no, then how can I convert a page from
"CodeBehind" model to "SRC" model ?

Thanks again,
Ali


"MSFT" <v-******@online.microsoft.com> wrote in message
news:dS**************@cpmsftngxa07.phx.gbl...
> Hi Richard,
>
> Thank you for using Microsoft Newsgroup Service. As for the question you > mentioned, the "SRC" attribute and "CodeBehind" attribute of the <%@Page > ..> Direction will specify different compile mode for the ASP.NET
web > page. Also, that will cause quite different effect when designing the > page's binded class at design-time. Here is the description in the

MSDN: >
> "CodeBehind" attribute:
> Specifies the name of the compiled file that contains the class

associated
> with the page. This attribute is used by the Visual Studio .NET Web

Forms
> designer. It tells the designer where to find the page class so that the > designer can create an instance of it for you to work with at design

time.
> For example, if you create a Web Forms page in Visual Studio called
> WebForm1, the designer will assign the Codebehind attribute the value of
> WebForm1.aspx.vb, for Visual Basic, or WebForm1.aspx.cs, for C#.
This > attribute is not used at run time.
>
> "SRC" attribute:
> Specifies the source file name of the code-behind class to dynamically > compile when the page is requested. You can choose to include

programming
> logic for your page either in a code-behind class or in a code

declaration
> block in the .aspx file.
>
> Note RAD designers, such as Visual Studio .NET, do not use this
> attribute. Instead, they precompile code-behind classes and then use

the > Inherits attribute.
>
> So if use "SRC" attribute, the IDE Designer won't get any of the page's > binded class info until the page is requested at runtime. Thus, when
> designing the page class source, it will lose the intelisence and
> generally IDE support for it.
>
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no > rights.)
>



Nov 18 '05 #7
> I am curious. I have tried using both but I get runtime errors for
ambiguous
names. Am I doing something wrong?
Obviously, yes. However, since you provided no detailed information about
what you did, or what the error messages were, that's all I can tell you.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"vMike" <Mi************@nospam.gewarren.com.delete> wrote in message
news:br**********@ngspool-d02.news.aol.com... I am curious. I have tried using both but I get runtime errors for ambiguous names. Am I doing something wrong?
Mike

"Kevin Spencer" <ke***@takempis.com> wrote in message
news:Oi**************@tk2msftngp13.phx.gbl...
You don't want to CHANGE "CodeBehind" to "Src" - you want to use BOTH.
"CodeBehind" tells the VS.Net IDE where to find the CodeBehind file at
design-time. "Src" tells your ASP.Net Page Template where to find it at
run-time.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"A.M" <IH*******@sapm123.com> wrote in message
news:O2**************@TK2MSFTNGP09.phx.gbl...

Thanks Steven for help.

I underestand the best way to have IDE support is using code behind.

We like to use SRC because we can use notepad to change the codes
whenever/wherever we want and ASP.NET will take care of compilation; however
we also would like to have IDE support during the actual development.

To achive what we need can i develop my web application with CodeBehind
page
attribute (to have IDE support during development) and right before
deployment change all CodeBehind page attribute to SRC ?

To re-phrase my question: If i develop my web application using CodeBehind page attribute, can i change "CodeBehinf" to "SRC" and my pages get

compiled
by ASP.NET? If the answer is no, then how can I convert a page from
"CodeBehind" model to "SRC" model ?

Thanks again,
Ali


"MSFT" <v-******@online.microsoft.com> wrote in message
news:dS**************@cpmsftngxa07.phx.gbl...
> Hi Richard,
>
> Thank you for using Microsoft Newsgroup Service. As for the question you > mentioned, the "SRC" attribute and "CodeBehind" attribute of the <%@Page > ..> Direction will specify different compile mode for the ASP.NET
web > page. Also, that will cause quite different effect when designing the > page's binded class at design-time. Here is the description in the

MSDN: >
> "CodeBehind" attribute:
> Specifies the name of the compiled file that contains the class

associated
> with the page. This attribute is used by the Visual Studio .NET Web

Forms
> designer. It tells the designer where to find the page class so that the > designer can create an instance of it for you to work with at design

time.
> For example, if you create a Web Forms page in Visual Studio called
> WebForm1, the designer will assign the Codebehind attribute the value of
> WebForm1.aspx.vb, for Visual Basic, or WebForm1.aspx.cs, for C#.
This > attribute is not used at run time.
>
> "SRC" attribute:
> Specifies the source file name of the code-behind class to dynamically > compile when the page is requested. You can choose to include

programming
> logic for your page either in a code-behind class or in a code

declaration
> block in the .aspx file.
>
> Note RAD designers, such as Visual Studio .NET, do not use this
> attribute. Instead, they precompile code-behind classes and then use

the > Inherits attribute.
>
> So if use "SRC" attribute, the IDE Designer won't get any of the page's > binded class info until the page is requested at runtime. Thus, when
> designing the page class source, it will lose the intelisence and
> generally IDE support for it.
>
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no > rights.)
>



Nov 18 '05 #8
> I tried having CodeBehind and SRC both together, it didn't worked. am i
missing something ?
Yup. But since you provided no details about exactly what you did and
exactly what the resulting behavior was, that's all I can tell you.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"A.M" <IH*******@sapm123.com> wrote in message
news:O8**************@TK2MSFTNGP12.phx.gbl...
I didn't know that i can have both. If what you are saying is possible then that would be greate, so i can develop/debug in VS.NET and after deployment (both .aspx and .aspx.vb files and no dll files) i can edit .aspx.vb files
with notepad upon any intsant cahnge requirements.

I tried having CodeBehind and SRC both together, it didn't worked. am i
missing something ?

Thanks for help,
Ali

"Kevin Spencer" <ke***@takempis.com> wrote in message
news:Oi**************@tk2msftngp13.phx.gbl...
You don't want to CHANGE "CodeBehind" to "Src" - you want to use BOTH.
"CodeBehind" tells the VS.Net IDE where to find the CodeBehind file at
design-time. "Src" tells your ASP.Net Page Template where to find it at
run-time.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"A.M" <IH*******@sapm123.com> wrote in message
news:O2**************@TK2MSFTNGP09.phx.gbl...

Thanks Steven for help.

I underestand the best way to have IDE support is using code behind.

We like to use SRC because we can use notepad to change the codes
whenever/wherever we want and ASP.NET will take care of compilation; however
we also would like to have IDE support during the actual development.

To achive what we need can i develop my web application with CodeBehind
page
attribute (to have IDE support during development) and right before
deployment change all CodeBehind page attribute to SRC ?

To re-phrase my question: If i develop my web application using CodeBehind page attribute, can i change "CodeBehinf" to "SRC" and my pages get

compiled
by ASP.NET? If the answer is no, then how can I convert a page from
"CodeBehind" model to "SRC" model ?

Thanks again,
Ali


"MSFT" <v-******@online.microsoft.com> wrote in message
news:dS**************@cpmsftngxa07.phx.gbl...
> Hi Richard,
>
> Thank you for using Microsoft Newsgroup Service. As for the question you > mentioned, the "SRC" attribute and "CodeBehind" attribute of the <%@Page > ..> Direction will specify different compile mode for the ASP.NET
web > page. Also, that will cause quite different effect when designing the > page's binded class at design-time. Here is the description in the

MSDN: >
> "CodeBehind" attribute:
> Specifies the name of the compiled file that contains the class

associated
> with the page. This attribute is used by the Visual Studio .NET Web

Forms
> designer. It tells the designer where to find the page class so that the > designer can create an instance of it for you to work with at design

time.
> For example, if you create a Web Forms page in Visual Studio called
> WebForm1, the designer will assign the Codebehind attribute the value of
> WebForm1.aspx.vb, for Visual Basic, or WebForm1.aspx.cs, for C#.
This > attribute is not used at run time.
>
> "SRC" attribute:
> Specifies the source file name of the code-behind class to dynamically > compile when the page is requested. You can choose to include

programming
> logic for your page either in a code-behind class or in a code

declaration
> block in the .aspx file.
>
> Note RAD designers, such as Visual Studio .NET, do not use this
> attribute. Instead, they precompile code-behind classes and then use

the > Inherits attribute.
>
> So if use "SRC" attribute, the IDE Designer won't get any of the page's > binded class info until the page is requested at runtime. Thus, when
> designing the page class source, it will lose the intelisence and
> generally IDE support for it.
>
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no > rights.)
>



Nov 18 '05 #9
vMike wrote:
I am curious. I have tried using both but I get runtime errors for ambiguous
names. Am I doing something wrong?
The problem is probably this:

VS.NET compiles your codebehind source into an assembly, which gets
deployed into the ASPX application's bin directory.

When you first load the page in the browser, the ASP.NET runtime sees
the src attribute and compiles that file into another assembly, which it
makes available for use by the app. Now when the parsed ASPX page is
compiled, it references both assemblies which have different classes
defined with the same name (the classes are different even though they
are compiled from the same code because they are in different assemblies).

You might be able to get the result you want by manually deleting from
the bin directory the assembly that VS.NET builds (maybe a custom build
step can handle that for you).

However, I predict that doing what you want to do will cause you major
pain if you use VS.NET.
Mike

"Kevin Spencer" <ke***@takempis.com> wrote in message
news:Oi**************@tk2msftngp13.phx.gbl...
You don't want to CHANGE "CodeBehind" to "Src" - you want to use BOTH.
"CodeBehind" tells the VS.Net IDE where to find the CodeBehind file at
design-time. "Src" tells your ASP.Net Page Template where to find it at
run-time.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"A.M" <IH*******@sapm123.com> wrote in message
news:O2**************@TK2MSFTNGP09.phx.gbl...
Thanks Steven for help.

I underestand the best way to have IDE support is using code behind.

We like to use SRC because we can use notepad to change the codes
whenever/wherever we want and ASP.NET will take care of compilation;


however
we also would like to have IDE support during the actual development.

To achive what we need can i develop my web application with CodeBehind


page
attribute (to have IDE support during development) and right before
deployment change all CodeBehind page attribute to SRC ?

To re-phrase my question: If i develop my web application using
CodeBehind
page attribute, can i change "CodeBehinf" to "SRC" and my pages get


compiled
by ASP.NET? If the answer is no, then how can I convert a page from
"CodeBehind" model to "SRC" model ?

Thanks again,
Ali


"MSFT" <v-******@online.microsoft.com> wrote in message
news:dS**************@cpmsftngxa07.phx.gbl...

Hi Richard,

Thank you for using Microsoft Newsgroup Service. As for the question
you
mentioned, the "SRC" attribute and "CodeBehind" attribute of the
<%@Page
..> Direction will specify different compile mode for the ASP.NET web
page. Also, that will cause quite different effect when designing the
page's binded class at design-time. Here is the description in the
MSDN:
"CodeBehind" attribute:
Specifies the name of the compiled file that contains the class


associated
with the page. This attribute is used by the Visual Studio .NET Web


Forms
designer. It tells the designer where to find the page class so that
the
designer can create an instance of it for you to work with at design


time.
For example, if you create a Web Forms page in Visual Studio called
WebForm1, the designer will assign the Codebehind attribute the value
of
WebForm1.aspx.vb, for Visual Basic, or WebForm1.aspx.cs, for C#. This
attribute is not used at run time.

"SRC" attribute:
Specifies the source file name of the code-behind class to dynamically
compile when the page is requested. You can choose to include


programming
logic for your page either in a code-behind class or in a code


declaration
block in the .aspx file.

Note RAD designers, such as Visual Studio .NET, do not use this
attribute. Instead, they precompile code-behind classes and then use
the
Inherits attribute.

So if use "SRC" attribute, the IDE Designer won't get any of the
page's
binded class info until the page is requested at runtime. Thus, when
designing the page class source, it will lose the intelisence and
generally IDE support for it.
Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



--
mikeb
Nov 18 '05 #10
Hi A.M,

Thank you for the reply. Yes, I know that you would like to change the page
attribute to "Src=filepath" mode since you want to do simple modified after
deploy them in webserver. I've done some further research on the Page Code
declaration. Here is some thing I found which may be useful for you:

In When create a ASP.NET apge in VS.NET ,by default, it use the Page code
direction like :
<%@ Page language="c#" Codebehind="MainPage.aspx.cs"
AutoEventWireup="false" Inherits="NewWebApp.MainPage" %>, This means the
certain page will use the class specified by the "Inherits" attribute to
instance a itself. the "Codebehind" attribute is used just for VS.NET IDE
to bind the relation between the aspx file and the aspx.cs file. And all
the classes defined in the Codebehind file will be precompiled into the
application assembly dll. When run the page, it find the class from the
assemply dll(won't compile the cs file again). However, if you want
everytime the ASP.NET runtime to compile the .cs file, you need to add the
"Src" attribute in the <@ Page ...> directive. But be care that don't
remove any other attributes, such as "Codebehind" and specially the
"Inherits". You should set the <@ page > directive as below:
<%@ Page language="c#" Codebehind="MainPage.aspx.cs"
AutoEventWireup="false" Inherits="NewWebApp.MainPage"
Src="MainPage.aspx.cs" %>

Thus, when the certain page is requested, the asp.net runtime will
dynamically compile the page using the file specified by "Src" attribute.

But there are something you must also care:
1. When you add the "Src" attribute to the page, you should removed the
original precompiled dll built by VS.NET, you can find it in the
WebApplication's Virutal Directory's "bin" sub folder. Delete them,
otherwise, you will get error says that you have redefined the certain page
class in multi places such as :

CS1595: 'NewWebApp.MainPage' is defined in multiple places; using
definition from 'f:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temp orary
ASP.NET
Files\newwebapp\01b345b1\ae5bd2c2\assembly\dl2\132 f2fd2\2c21bb78_52c5c301\Ne
wWebApp.DLL'

2. Since by default, all the pages or globa object's class are all
precompiled in the application assembly dll. If you delete the
application's dll, maybe some other class in it will be unable to find. For
example , maybe you have a globa.asax file which bind with a global.asax.cs
file, so you must also change its code directive, such as :

(open the global.asax file using notpad)
<%@ Application Codebehind="Global.asax.cs" Inherits="NewWebApp.Global"
Src="Global.asax.cs" %>
Add the Src="Global.asax.cs" into it so that make the global object also
compile dynamically .
Also, you can set part of your pages using the "Src" and part of them not,
but do care that don't include the class which has set "Src" attribute when
the VS.NET build the application assemly.

If you feel anything unclear in my description, you can visit the following
KB for more detailed info about

HOW TO: Work with Code-Behind Class Files in an ASP.NET Application by
Using Visual Basic .NET

http://support.microsoft.com/default...b;en-us;312311

Please try the preceding suggestion and see whether they help you.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Nov 18 '05 #11
Hi A.M,
Have you had a chance to try out my suggestion or have your problem been
resolved? Please feel free to let me know if you have any problem on it.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #12
HI A,M,

Have you got any progress on this issue? Please feel free to let me know
if you have any questions.

Steven Cheng
Microsoft Online Support

Nov 18 '05 #13

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

Similar topics

2
by: Graham Allwood | last post by:
I'm reading the Essential ASP.NET book by Fritz onion and he says that when VS.NET creates a new .aspx page for you is uses the codebehind attribute on the Page directive rather than the src...
6
by: Thomas Connolly | last post by:
I have 2 pages referencing the same codebehind file in my project. Originally the pages referenced separate code behind files. Once I changed the reference to the same file, everything worked...
12
by: Karl Hungus | last post by:
If I use a code behind class for an aspx page, what is the best way to get data from the codebehind class into my aspx page? I know about databinding, but is there a more basic way of just...
3
by: jm | last post by:
I have a question about codebehind. I have an upload namespace, class and all in a codebehind. I currently have it so it works with one of my .aspx pages. I want to use it for another .aspx...
4
by: darrel | last post by:
I have a contact form that a person submits to the server. In ASP, you'd make a page, post the form to another page, which would grab the values and do somethign with them. in ASP.NET, it...
7
by: Jack | last post by:
Hello, What is the difference between SRC and CODEBEHIND Tags? Example <%@ Page Language="vb" ValidateRequest="false" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" %> or
1
by: Randall Parker | last post by:
Using VS 2003 and Cassini web server. I'm new to ASP.Net and so this may be a dumb question. I'm getting an error where the type 'FarmLand.WebForm1' is not found. The Codebehind C# source file...
6
by: antonyliu2002 | last post by:
Right now I put my VB code in the aspx pages. I would prefer to use codebehind, especially many of my VB functions may be shared across multiple aspx pages. I've tried a few pages with...
6
by: WT | last post by:
Hello, I am searching for a way to generate automatically from codebehind the <!Doctype....for asp.net pages using .net 3.5 c# and vs2008. Subidiary question: if I do a server transfert in my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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,...
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...

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.