By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,187 Members | 1,038 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,187 IT Pros & Developers. It's quick & easy.

SRC instead of CodeBehind

P: n/a
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
Share this Question
Share on Google+
12 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
> 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

P: n/a
> 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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.