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

Unable to set a string to Include statement

P: n/a
In my User control, I tried to do this:
************************************************** *************************
<Script runat="server">
Public ClientName As String = "<!-- #include file =
...\includes\StaffingHeaders.inc -->"

</Script>

<%=ClientName%>
************************************************** **************************

This gives me:

Parser Error Message: Server includes are not allowed in server script
tags.
If I try to do it this way:
In my User control, I tried to do this:
************************************************** *************************
<Script runat="server">
Public ClientName As String = "<!-- #" & "include file =
...\includes\StaffingHeaders.inc -->"

</Script>

<%=ClientName%>
************************************************** **************************

It gives me nothing

If I do this:
************************************************** *************************
<Script runat="server">
Public ClientName As String = "!-- #" & "include file =
...\includes\StaffingHeaders.inc -->"

</Script>

<%=ClientName%>
************************************************** **************************
As I would expect, it displays:

"!-- #include file = ..\includes\StaffingHeaders.inc -->

But as soon as I add the "<", I get the error.

This should just be a string, why isn't it?

Tom
Nov 18 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
What in the world are you trying to do?
It looks like you want to add an include file in your page. Which, I think,
is still allowed in
ASP.NET for backward compatibility. But that's the only reason why it's
there, you should not be using in ASP.NET.

If you want just to have include file in your page just add
<!-- #include file ="...\includes\StaffingHeaders.inc"> OUTSIDE server script.

This line will be Parsed by ASP and hopefully .inc file will be executed.
But Response.Write which you were doing in your examples will simply send
that string to the browser.

My advise don't use includes in .NET, since it's really old 'classic' asp
feature. Instead adopt OO programming approach.

"tshad" wrote:
In my User control, I tried to do this:
************************************************** *************************
<Script runat="server">
Public ClientName As String = "<!-- #include file =
...\includes\StaffingHeaders.inc -->"

</Script>

<%=ClientName%>
************************************************** **************************

This gives me:

Parser Error Message: Server includes are not allowed in server script
tags.
If I try to do it this way:
In my User control, I tried to do this:
************************************************** *************************
<Script runat="server">
Public ClientName As String = "<!-- #" & "include file =
...\includes\StaffingHeaders.inc -->"

</Script>

<%=ClientName%>
************************************************** **************************

It gives me nothing

If I do this:
************************************************** *************************
<Script runat="server">
Public ClientName As String = "!-- #" & "include file =
...\includes\StaffingHeaders.inc -->"

</Script>

<%=ClientName%>
************************************************** **************************
As I would expect, it displays:

"!-- #include file = ..\includes\StaffingHeaders.inc -->

But as soon as I add the "<", I get the error.

This should just be a string, why isn't it?

Tom

Nov 18 '05 #2

P: n/a
"WebMatrix" <We*******@discussions.microsoft.com> wrote in message
news:9A**********************************@microsof t.com...
What in the world are you trying to do?
It looks like you want to add an include file in your page. Which, I
think,
is still allowed in
ASP.NET for backward compatibility. But that's the only reason why it's
there, you should not be using in ASP.NET.

If you want just to have include file in your page just add
<!-- #include file ="...\includes\StaffingHeaders.inc"> OUTSIDE server
script.

This line will be Parsed by ASP and hopefully .inc file will be executed.
But Response.Write which you were doing in your examples will simply send
that string to the browser.

My advise don't use includes in .NET, since it's really old 'classic' asp
feature. Instead adopt OO programming approach.
Actually, that is what I am in the midst of doing now.

My question is why would the parser give me an error on setting up the
string?

If it is in quotes, why would it not accept it?

Isn't the following a valid string?

Public ClientName As String = "<!-- #include file =
....\includes\StaffingHeaders.inc -->"

Also, assuming I can set a variable to the inlude string, outside of the
Script tags, isn't:

<!-- #include file = ...\includes\StaffingHeaders.inc -->

the same as:

<%=ClientName%>.

I was under the impression (and I could be wrong) that <%ClientName%> would
be replaced with:

<!-- #include file = ...\includes\StaffingHeaders.inc -->

Am I wrong here?

Thanks,

Tom


"tshad" wrote:
In my User control, I tried to do this:
************************************************** *************************
<Script runat="server">
Public ClientName As String = "<!-- #include file =
...\includes\StaffingHeaders.inc -->"

</Script>

<%=ClientName%>
************************************************** **************************

This gives me:

Parser Error Message: Server includes are not allowed in server script
tags.
If I try to do it this way:
In my User control, I tried to do this:
************************************************** *************************
<Script runat="server">
Public ClientName As String = "<!-- #" & "include file =
...\includes\StaffingHeaders.inc -->"

</Script>

<%=ClientName%>
************************************************** **************************

It gives me nothing

If I do this:
************************************************** *************************
<Script runat="server">
Public ClientName As String = "!-- #" & "include file =
...\includes\StaffingHeaders.inc -->"

</Script>

<%=ClientName%>
************************************************** **************************
As I would expect, it displays:

"!-- #include file = ..\includes\StaffingHeaders.inc -->

But as soon as I add the "<", I get the error.

This should just be a string, why isn't it?

Tom

Nov 18 '05 #3

P: n/a
You are missing 2 points:
1. Include file is a legacy asp feature, the replacement for includes in
..NET world are things like server-side user controls, and plain .NET Claasses.

2. If you absolutely must use includes then try to understand how web server
parses web pages.
Everything outside Server Script will be parsed as HTML and served to the
browser. So having
<%=ClientName%> will simply render whatever value that variable holds.
However having this text outside server side tags
<!-- #include file =" ....\includes\StaffingHeaders.inc" --> tells parser
that this is an include file that needs to be executed.

From what I am seeing, you're trying to execute certain piece of code
dynamically. I think you'll be better off investigating .NET features that
could accomplish your goal. In any case, if you provide more details on what
you're trying to accomplish perhaps someone could steer you to the right
direction.


"tshad" wrote:
"WebMatrix" <We*******@discussions.microsoft.com> wrote in message
news:9A**********************************@microsof t.com...
What in the world are you trying to do?
It looks like you want to add an include file in your page. Which, I
think,
is still allowed in
ASP.NET for backward compatibility. But that's the only reason why it's
there, you should not be using in ASP.NET.

If you want just to have include file in your page just add
<!-- #include file ="...\includes\StaffingHeaders.inc"> OUTSIDE server
script.

This line will be Parsed by ASP and hopefully .inc file will be executed.
But Response.Write which you were doing in your examples will simply send
that string to the browser.

My advise don't use includes in .NET, since it's really old 'classic' asp
feature. Instead adopt OO programming approach.


Actually, that is what I am in the midst of doing now.

My question is why would the parser give me an error on setting up the
string?

If it is in quotes, why would it not accept it?

Isn't the following a valid string?

Public ClientName As String = "<!-- #include file =
....\includes\StaffingHeaders.inc -->"

Also, assuming I can set a variable to the inlude string, outside of the
Script tags, isn't:

<!-- #include file = ...\includes\StaffingHeaders.inc -->

the same as:

<%=ClientName%>.

I was under the impression (and I could be wrong) that <%ClientName%> would
be replaced with:

<!-- #include file = ...\includes\StaffingHeaders.inc -->

Am I wrong here?

Thanks,

Tom


"tshad" wrote:
In my User control, I tried to do this:
************************************************** *************************
<Script runat="server">
Public ClientName As String = "<!-- #include file =
...\includes\StaffingHeaders.inc -->"

</Script>

<%=ClientName%>
************************************************** **************************

This gives me:

Parser Error Message: Server includes are not allowed in server script
tags.
If I try to do it this way:
In my User control, I tried to do this:
************************************************** *************************
<Script runat="server">
Public ClientName As String = "<!-- #" & "include file =
...\includes\StaffingHeaders.inc -->"

</Script>

<%=ClientName%>
************************************************** **************************

It gives me nothing

If I do this:
************************************************** *************************
<Script runat="server">
Public ClientName As String = "!-- #" & "include file =
...\includes\StaffingHeaders.inc -->"

</Script>

<%=ClientName%>
************************************************** **************************
As I would expect, it displays:

"!-- #include file = ..\includes\StaffingHeaders.inc -->

But as soon as I add the "<", I get the error.

This should just be a string, why isn't it?

Tom


Nov 18 '05 #4

P: n/a
"WebMatrix" <We*******@discussions.microsoft.com> wrote in message
news:B9**********************************@microsof t.com...
You are missing 2 points:
1. Include file is a legacy asp feature, the replacement for includes in
.NET world are things like server-side user controls, and plain .NET
Claasses.

2. If you absolutely must use includes then try to understand how web
server
parses web pages.
Everything outside Server Script will be parsed as HTML and served to the
browser. So having
<%=ClientName%> will simply render whatever value that variable holds.
However having this text outside server side tags
<!-- #include file =" ....\includes\StaffingHeaders.inc" --> tells parser
that this is an include file that needs to be executed.

From what I am seeing, you're trying to execute certain piece of code
dynamically. I think you'll be better off investigating .NET features that
could accomplish your goal. In any case, if you provide more details on
what
you're trying to accomplish perhaps someone could steer you to the right
direction.


Actually, I have 2 problems (but I will forgo the inability to set a string
to the include statement - which makes no sense at all).

What I am trying to do is create a general aspx page that has all my normal
processing, except for the top and bottom sections of the pages which are
the company logos, menus etc.

I want to be able go to different companies, have them give me their top
sections (headers) and bottom sections (footers). I would then include them
like so:

************************************************** ****************************************
<%@ Register TagPrefix="fts" TAgName="header"
src="..\includes\travacHeaders.ascx" %>
<%@ Register TagPrefix="fts" TAgName="footer"
src="..\includes\travacFooters.ascx" %>
<%@ Page Language="VB" trace="false" debug="true" AutoEventWireup="true"
ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<script runat="server">
sub Page_load(s as object,e as eventargs)
end sub
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Home Page</title>

<!-- Clients Headers are displayed here -->
<fts:header id=ctl1 runat="Server" />

<!-- Our Content Starts Here -->
<form id="Form1" runat="server">
<input type="hidden" name="__SCROLLPOS" value="" />
<center>
<br>
</center>
</form>

<!-- Our Content Ends Here -->

<!-- Clients Footers are displayed here -->
<fts:footer id=cdl2 runat="Server" />
************************************************** ****************************************

The problem with the above code is that it works fine for only one client.
I don't want to create the above page for each client. I would have
travacHeaders.ascx for one client, staffersHeaders.ascx for another client,
etc.

Originally, I tried to set up a control to call different include files:

************************************************** *****************************************
<Script runat="server">
Public ClientName As String = "<!-- #include file " & "=
...\includes\travacHeaders.inc -->"

</Script>

<%=ClientName%>
************************************************** *****************************************

One of the problem is that ASP, won't let me set the string to the incude
statement (and you say this won't work anyway).

How do I set this up to call different controls (or include files)?

Thanks,

Tom


"tshad" wrote:
"WebMatrix" <We*******@discussions.microsoft.com> wrote in message
news:9A**********************************@microsof t.com...
> What in the world are you trying to do?
> It looks like you want to add an include file in your page. Which, I
> think,
> is still allowed in
> ASP.NET for backward compatibility. But that's the only reason why it's
> there, you should not be using in ASP.NET.
>
> If you want just to have include file in your page just add
> <!-- #include file ="...\includes\StaffingHeaders.inc"> OUTSIDE server
> script.
>
> This line will be Parsed by ASP and hopefully .inc file will be
> executed.
> But Response.Write which you were doing in your examples will simply
> send
> that string to the browser.
>
> My advise don't use includes in .NET, since it's really old 'classic'
> asp
> feature. Instead adopt OO programming approach.


Actually, that is what I am in the midst of doing now.

My question is why would the parser give me an error on setting up the
string?

If it is in quotes, why would it not accept it?

Isn't the following a valid string?

Public ClientName As String = "<!-- #include file =
....\includes\StaffingHeaders.inc -->"

Also, assuming I can set a variable to the inlude string, outside of the
Script tags, isn't:

<!-- #include file = ...\includes\StaffingHeaders.inc -->

the same as:

<%=ClientName%>.

I was under the impression (and I could be wrong) that <%ClientName%>
would
be replaced with:

<!-- #include file = ...\includes\StaffingHeaders.inc -->

Am I wrong here?

Thanks,

Tom

>
> "tshad" wrote:
>
>> In my User control, I tried to do this:
>> ************************************************** *************************
>> <Script runat="server">
>> Public ClientName As String = "<!-- #include file =
>> ...\includes\StaffingHeaders.inc -->"
>>
>> </Script>
>>
>> <%=ClientName%>
>> ************************************************** **************************
>>
>> This gives me:
>>
>> Parser Error Message: Server includes are not allowed in server
>> script
>> tags.
>>
>>
>> If I try to do it this way:
>> In my User control, I tried to do this:
>> ************************************************** *************************
>> <Script runat="server">
>> Public ClientName As String = "<!-- #" & "include file =
>> ...\includes\StaffingHeaders.inc -->"
>>
>> </Script>
>>
>> <%=ClientName%>
>> ************************************************** **************************
>>
>> It gives me nothing
>>
>> If I do this:
>> ************************************************** *************************
>> <Script runat="server">
>> Public ClientName As String = "!-- #" & "include file =
>> ...\includes\StaffingHeaders.inc -->"
>>
>> </Script>
>>
>> <%=ClientName%>
>> ************************************************** **************************
>> As I would expect, it displays:
>>
>> "!-- #include file = ..\includes\StaffingHeaders.inc -->
>>
>> But as soon as I add the "<", I get the error.
>>
>> This should just be a string, why isn't it?
>>
>> Tom
>>
>>
>>


Nov 18 '05 #5

P: n/a
So you are using User Control (.ascx file). Why don't you program your
control to render different content based on the client logged into your
site? For example place image control where company logo should go, and store
image name + path for each client in AppSettings section of web.config file
like that:
<add key="Client1" value = "~/images/Client1Logo.gif" />
<add key="Client2" value = "~/images/Client2Logo.gif" />

In your Control you can retrieve logo path by the client name from a
webconfig file and set ImageUrl property of your logo image control Control
like this:

imgLogo.ImageURL =
Page.resolveURL(System.Configuration.Configuration Settings.AppSettings().Item(ClientName))

Similar techniques can be applied for other dynamic elements of your control.
but I will forgo the inability to set a string to the include statement - which makes no sense at all


No it makes perfect sense. Think about it. What would happen if you did this:
Response.Write("<!--#include file=""somefile.inc"" -->")
????

"tshad" wrote:
"WebMatrix" <We*******@discussions.microsoft.com> wrote in message
news:B9**********************************@microsof t.com...
You are missing 2 points:
1. Include file is a legacy asp feature, the replacement for includes in
.NET world are things like server-side user controls, and plain .NET
Claasses.

2. If you absolutely must use includes then try to understand how web
server
parses web pages.
Everything outside Server Script will be parsed as HTML and served to the
browser. So having
<%=ClientName%> will simply render whatever value that variable holds.
However having this text outside server side tags
<!-- #include file =" ....\includes\StaffingHeaders.inc" --> tells parser
that this is an include file that needs to be executed.

From what I am seeing, you're trying to execute certain piece of code
dynamically. I think you'll be better off investigating .NET features that
could accomplish your goal. In any case, if you provide more details on
what
you're trying to accomplish perhaps someone could steer you to the right
direction.


Actually, I have 2 problems (but I will forgo the inability to set a string
to the include statement - which makes no sense at all).

What I am trying to do is create a general aspx page that has all my normal
processing, except for the top and bottom sections of the pages which are
the company logos, menus etc.

I want to be able go to different companies, have them give me their top
sections (headers) and bottom sections (footers). I would then include them
like so:

************************************************** ****************************************
<%@ Register TagPrefix="fts" TAgName="header"
src="..\includes\travacHeaders.ascx" %>
<%@ Register TagPrefix="fts" TAgName="footer"
src="..\includes\travacFooters.ascx" %>
<%@ Page Language="VB" trace="false" debug="true" AutoEventWireup="true"
ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<script runat="server">
sub Page_load(s as object,e as eventargs)
end sub
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Home Page</title>

<!-- Clients Headers are displayed here -->
<fts:header id=ctl1 runat="Server" />

<!-- Our Content Starts Here -->
<form id="Form1" runat="server">
<input type="hidden" name="__SCROLLPOS" value="" />
<center>
<br>
</center>
</form>

<!-- Our Content Ends Here -->

<!-- Clients Footers are displayed here -->
<fts:footer id=cdl2 runat="Server" />
************************************************** ****************************************

The problem with the above code is that it works fine for only one client.
I don't want to create the above page for each client. I would have
travacHeaders.ascx for one client, staffersHeaders.ascx for another client,
etc.

Originally, I tried to set up a control to call different include files:

************************************************** *****************************************
<Script runat="server">
Public ClientName As String = "<!-- #include file " & "=
...\includes\travacHeaders.inc -->"

</Script>

<%=ClientName%>
************************************************** *****************************************

One of the problem is that ASP, won't let me set the string to the incude
statement (and you say this won't work anyway).

How do I set this up to call different controls (or include files)?

Thanks,

Tom


"tshad" wrote:
"WebMatrix" <We*******@discussions.microsoft.com> wrote in message
news:9A**********************************@microsof t.com...
> What in the world are you trying to do?
> It looks like you want to add an include file in your page. Which, I
> think,
> is still allowed in
> ASP.NET for backward compatibility. But that's the only reason why it's
> there, you should not be using in ASP.NET.
>
> If you want just to have include file in your page just add
> <!-- #include file ="...\includes\StaffingHeaders.inc"> OUTSIDE server
> script.
>
> This line will be Parsed by ASP and hopefully .inc file will be
> executed.
> But Response.Write which you were doing in your examples will simply
> send
> that string to the browser.
>
> My advise don't use includes in .NET, since it's really old 'classic'
> asp
> feature. Instead adopt OO programming approach.

Actually, that is what I am in the midst of doing now.

My question is why would the parser give me an error on setting up the
string?

If it is in quotes, why would it not accept it?

Isn't the following a valid string?

Public ClientName As String = "<!-- #include file =
....\includes\StaffingHeaders.inc -->"

Also, assuming I can set a variable to the inlude string, outside of the
Script tags, isn't:

<!-- #include file = ...\includes\StaffingHeaders.inc -->

the same as:

<%=ClientName%>.

I was under the impression (and I could be wrong) that <%ClientName%>
would
be replaced with:

<!-- #include file = ...\includes\StaffingHeaders.inc -->

Am I wrong here?

Thanks,

Tom
>
> "tshad" wrote:
>
>> In my User control, I tried to do this:
>> ************************************************** *************************
>> <Script runat="server">
>> Public ClientName As String = "<!-- #include file =
>> ...\includes\StaffingHeaders.inc -->"
>>
>> </Script>
>>
>> <%=ClientName%>
>> ************************************************** **************************
>>
>> This gives me:
>>
>> Parser Error Message: Server includes are not allowed in server
>> script
>> tags.
>>
>>
>> If I try to do it this way:
>> In my User control, I tried to do this:
>> ************************************************** *************************
>> <Script runat="server">
>> Public ClientName As String = "<!-- #" & "include file =
>> ...\includes\StaffingHeaders.inc -->"
>>
>> </Script>
>>
>> <%=ClientName%>
>> ************************************************** **************************
>>
>> It gives me nothing
>>
>> If I do this:
>> ************************************************** *************************
>> <Script runat="server">
>> Public ClientName As String = "!-- #" & "include file =
>> ...\includes\StaffingHeaders.inc -->"
>>
>> </Script>
>>
>> <%=ClientName%>
>> ************************************************** **************************
>> As I would expect, it displays:
>>
>> "!-- #include file = ..\includes\StaffingHeaders.inc -->
>>
>> But as soon as I add the "<", I get the error.
>>
>> This should just be a string, why isn't it?
>>
>> Tom
>>
>>
>>


Nov 18 '05 #6

P: n/a
"WebMatrix" <We*******@discussions.microsoft.com> wrote in message
news:E3**********************************@microsof t.com...
So you are using User Control (.ascx file). Why don't you program your
control to render different content based on the client logged into your
site? For example place image control where company logo should go, and
store
image name + path for each client in AppSettings section of web.config
file
like that:
<add key="Client1" value = "~/images/Client1Logo.gif" />
<add key="Client2" value = "~/images/Client2Logo.gif" />

In your Control you can retrieve logo path by the client name from a
webconfig file and set ImageUrl property of your logo image control
Control
like this:

imgLogo.ImageURL =
Page.resolveURL(System.Configuration.Configuration Settings.AppSettings().Item(ClientName))

Similar techniques can be applied for other dynamic elements of your
control.
That is what I was looking for. I just need to look at this closer to
understand what you are doing.
but I will forgo the inability to set a string to the include statement - which makes no sense at all


No it makes perfect sense. Think about it. What would happen if you did
this:
Response.Write("<!--#include file=""somefile.inc"" -->")
????


You're right. I never noticed the quotes before. Brain fade.

Thanks,

Tom.
"tshad" wrote:
"WebMatrix" <We*******@discussions.microsoft.com> wrote in message
news:B9**********************************@microsof t.com...
> You are missing 2 points:
> 1. Include file is a legacy asp feature, the replacement for includes
> in
> .NET world are things like server-side user controls, and plain .NET
> Claasses.
>
> 2. If you absolutely must use includes then try to understand how web
> server
> parses web pages.
> Everything outside Server Script will be parsed as HTML and served to
> the
> browser. So having
> <%=ClientName%> will simply render whatever value that variable holds.
> However having this text outside server side tags
> <!-- #include file =" ....\includes\StaffingHeaders.inc" --> tells
> parser
> that this is an include file that needs to be executed.
>
> From what I am seeing, you're trying to execute certain piece of code
> dynamically. I think you'll be better off investigating .NET features
> that
> could accomplish your goal. In any case, if you provide more details on
> what
> you're trying to accomplish perhaps someone could steer you to the
> right
> direction.
>
>


Actually, I have 2 problems (but I will forgo the inability to set a
string
to the include statement - which makes no sense at all).

What I am trying to do is create a general aspx page that has all my
normal
processing, except for the top and bottom sections of the pages which are
the company logos, menus etc.

I want to be able go to different companies, have them give me their top
sections (headers) and bottom sections (footers). I would then include
them
like so:

************************************************** ****************************************
<%@ Register TagPrefix="fts" TAgName="header"
src="..\includes\travacHeaders.ascx" %>
<%@ Register TagPrefix="fts" TAgName="footer"
src="..\includes\travacFooters.ascx" %>
<%@ Page Language="VB" trace="false" debug="true" AutoEventWireup="true"
ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<script runat="server">
sub Page_load(s as object,e as eventargs)
end sub
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Home Page</title>

<!-- Clients Headers are displayed here -->
<fts:header id=ctl1 runat="Server" />

<!-- Our Content Starts Here -->
<form id="Form1" runat="server">
<input type="hidden" name="__SCROLLPOS" value="" />
<center>
<br>
</center>
</form>

<!-- Our Content Ends Here -->

<!-- Clients Footers are displayed here -->
<fts:footer id=cdl2 runat="Server" />
************************************************** ****************************************

The problem with the above code is that it works fine for only one
client.
I don't want to create the above page for each client. I would have
travacHeaders.ascx for one client, staffersHeaders.ascx for another
client,
etc.

Originally, I tried to set up a control to call different include files:

************************************************** *****************************************
<Script runat="server">
Public ClientName As String = "<!-- #include file " & "=
...\includes\travacHeaders.inc -->"

</Script>

<%=ClientName%>
************************************************** *****************************************

One of the problem is that ASP, won't let me set the string to the incude
statement (and you say this won't work anyway).

How do I set this up to call different controls (or include files)?

Thanks,

Tom
>
>
> "tshad" wrote:
>
>> "WebMatrix" <We*******@discussions.microsoft.com> wrote in message
>> news:9A**********************************@microsof t.com...
>> > What in the world are you trying to do?
>> > It looks like you want to add an include file in your page. Which, I
>> > think,
>> > is still allowed in
>> > ASP.NET for backward compatibility. But that's the only reason why
>> > it's
>> > there, you should not be using in ASP.NET.
>> >
>> > If you want just to have include file in your page just add
>> > <!-- #include file ="...\includes\StaffingHeaders.inc"> OUTSIDE
>> > server
>> > script.
>> >
>> > This line will be Parsed by ASP and hopefully .inc file will be
>> > executed.
>> > But Response.Write which you were doing in your examples will simply
>> > send
>> > that string to the browser.
>> >
>> > My advise don't use includes in .NET, since it's really old
>> > 'classic'
>> > asp
>> > feature. Instead adopt OO programming approach.
>>
>> Actually, that is what I am in the midst of doing now.
>>
>> My question is why would the parser give me an error on setting up the
>> string?
>>
>> If it is in quotes, why would it not accept it?
>>
>> Isn't the following a valid string?
>>
>> Public ClientName As String = "<!-- #include file =
>> ....\includes\StaffingHeaders.inc -->"
>>
>> Also, assuming I can set a variable to the inlude string, outside of
>> the
>> Script tags, isn't:
>>
>> <!-- #include file = ...\includes\StaffingHeaders.inc -->
>>
>> the same as:
>>
>> <%=ClientName%>.
>>
>> I was under the impression (and I could be wrong) that <%ClientName%>
>> would
>> be replaced with:
>>
>> <!-- #include file = ...\includes\StaffingHeaders.inc -->
>>
>> Am I wrong here?
>>
>> Thanks,
>>
>> Tom
>>
>>
>> >
>> > "tshad" wrote:
>> >
>> >> In my User control, I tried to do this:
>> >> ************************************************** *************************
>> >> <Script runat="server">
>> >> Public ClientName As String = "<!-- #include file =
>> >> ...\includes\StaffingHeaders.inc -->"
>> >>
>> >> </Script>
>> >>
>> >> <%=ClientName%>
>> >> ************************************************** **************************
>> >>
>> >> This gives me:
>> >>
>> >> Parser Error Message: Server includes are not allowed in server
>> >> script
>> >> tags.
>> >>
>> >>
>> >> If I try to do it this way:
>> >> In my User control, I tried to do this:
>> >> ************************************************** *************************
>> >> <Script runat="server">
>> >> Public ClientName As String = "<!-- #" & "include file =
>> >> ...\includes\StaffingHeaders.inc -->"
>> >>
>> >> </Script>
>> >>
>> >> <%=ClientName%>
>> >> ************************************************** **************************
>> >>
>> >> It gives me nothing
>> >>
>> >> If I do this:
>> >> ************************************************** *************************
>> >> <Script runat="server">
>> >> Public ClientName As String = "!-- #" & "include file =
>> >> ...\includes\StaffingHeaders.inc -->"
>> >>
>> >> </Script>
>> >>
>> >> <%=ClientName%>
>> >> ************************************************** **************************
>> >> As I would expect, it displays:
>> >>
>> >> "!-- #include file = ..\includes\StaffingHeaders.inc -->
>> >>
>> >> But as soon as I add the "<", I get the error.
>> >>
>> >> This should just be a string, why isn't it?
>> >>
>> >> Tom
>> >>
>> >>
>> >>
>>
>>
>>


Nov 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.