Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Check out this very cool trick!

cool hack!

MCA

"Thomas Kadlec" <kadlect@hotmail.com> wrote in message
news:39b81c65$1@news.dev-archive.com...
> I came up with this really interesting trick today and thought it was well
> worth sharing...
>
> Please use with caution and testing before you try this.. use at your own
> risk!
>
> If you use Visual InterDev and want your asp+ C# or VB code syntax color
> coded do this:
>
> 1) right click on any .aspx or .cs file in your project, choose 'open
with'
> and make the default editor "HTML editor"
>
> 2) at the top of your .aspx pages add these lines: (replace test.aspx
with
> whatever you want)
>
> <%-- '*** test.aspx ***'
> <%@ Page Language="JScript" %> --%>
>
> 3) at the top of your .cs files add this line:
>
> //<script '*** test.aspx ***'>
>
> Viola!!! your C# code is now color coded!!
>
> InterDev is fooled into thinking it is looking at jscript code (and colors
> it as such) but because of the similarities of the two languages you will
> hardly be able to tell the difference and it is very nice to have your
> comments in green and key words in blue etc.
>
> In both cases the lines you entered above are completely ignored by the
aspx
> engine because they are commented out by either the new <%-- --%>
serverside
> comment (in step 2) or the c# // comment (in step 3) As you write your
> .aspx you should pretend that the file was completely empty.. i.e. even
> though there is that @page directive there you must realize that for all
> intents and purposes as far as your .aspx page goes it ISN'T there.
>
> so a real .aspx page might start of like this:
>
> <%-- '*** test.aspx ***'
> <%@ Page Language="JScript" %> --%>
> <%@ Page Language="c#" %>
>
> Again the first two lines are ignored by the asp+ engine their only
purpose
> is to fool Interdev that the page is javascript so it will colorcode your
c#
> code The third line would be your 'real' @ Page Directive. everything
below
> you would write just as you have been doing .aspx files.
>
> A bonus is that even autocomplete will work for built in objects like
> "Session" or "Server" from asp 3.0 javascript. of course this could get
you
> into trouble being as there are differences in the new objects (so use
that
> feature cautiously)
>
> This can be applied to vb code as will only in your .vb files... (I
haven't
> tested this with vb code so you might have to play with getting it to work
> but I know it is possible as long as you understand the general concept)
>
> for .aspx files:
> <%-- '*** test.aspx ***'
> <%@ Page Language="VBScript" %> --%>
>
> for .vb files:
> '<script '*** test.aspx ***'>
>
> Hope you are as excited by this as I am! ;-)
> All I can say is WOO HOO! Boy does this make life easier!
>
> Thomas Kadlec
> kadlect@hotmail.com
>
>
>
>
>
>
>
[3512 byte] By [Mike Amundsen] at [2007-11-9 18:21:55]
# 1 Re: Check out this very cool trick!
I came up with this really interesting trick today and thought it was well
worth sharing...

Please use with caution and testing before you try this.. use at your own
risk!

If you use Visual InterDev and want your asp+ C# or VB code syntax color
coded do this:

1) right click on any .aspx or .cs file in your project, choose 'open with'
and make the default editor "HTML editor"

2) at the top of your .aspx pages add these lines: (replace test.aspx with
whatever you want)

<%-- '*** test.aspx ***'
<%@ Page Language="JScript" %> --%>

3) at the top of your .cs files add this line:

//<script '*** test.aspx ***'>

Viola!!! your C# code is now color coded!!

InterDev is fooled into thinking it is looking at jscript code (and colors
it as such) but because of the similarities of the two languages you will
hardly be able to tell the difference and it is very nice to have your
comments in green and key words in blue etc.

In both cases the lines you entered above are completely ignored by the aspx
engine because they are commented out by either the new <%-- --%> serverside
comment (in step 2) or the c# // comment (in step 3) As you write your
..aspx you should pretend that the file was completely empty.. i.e. even
though there is that @page directive there you must realize that for all
intents and purposes as far as your .aspx page goes it ISN'T there.

so a real .aspx page might start of like this:

<%-- '*** test.aspx ***'
<%@ Page Language="JScript" %> --%>
<%@ Page Language="c#" %>

Again the first two lines are ignored by the asp+ engine their only purpose
is to fool Interdev that the page is javascript so it will colorcode your c#
code The third line would be your 'real' @ Page Directive. everything below
you would write just as you have been doing .aspx files.

A bonus is that even autocomplete will work for built in objects like
"Session" or "Server" from asp 3.0 javascript. of course this could get you
into trouble being as there are differences in the new objects (so use that
feature cautiously)

This can be applied to vb code as will only in your .vb files... (I haven't
tested this with vb code so you might have to play with getting it to work
but I know it is possible as long as you understand the general concept)

for .aspx files:
<%-- '*** test.aspx ***'
<%@ Page Language="VBScript" %> --%>

for .vb files:
'<script '*** test.aspx ***'>

Hope you are as excited by this as I am! ;-)
All I can say is WOO HOO! Boy does this make life easier!

Thomas Kadlec
kadlect@hotmail.com
Thomas Kadlec at 2007-11-11 22:28:44 >