Executing a var within an aspx .inc file?

This is a discussion on Executing a var within an aspx .inc file? within the CSharp forums in Programming Languages category; All, How do you write out a variable in a ASPX .inc?? I've used the following in my code and it worked until I changed the date & MyWebSite, to a server side write... is there any way of getting this to work within an inc file structure? Thanks in advance. - CES <% Response.WriteFile("Yourfile.FileExtension"); %> ----- Yourfile.FileExtension ------ <div id="copyright"> Copyright <%=DateTime.Now.Year.ToString()%> - <%=MyWebSite%> - All rights reserved. <br />Use of this site signifies the users complete agreement to all terms, contained <br />&amp; described within the Terms of Use page (Updated July 31, 2008) </div>...

Go Back   Application Development Forum > Programming Languages > CSharp

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-27-2008, 10:19 PM
CES
Guest
 
Default Executing a var within an aspx .inc file?

All,
How do you write out a variable in a ASPX .inc?? I've used the following in
my code and it worked until I changed the date & MyWebSite, to a server side
write... is there any way of getting this to work within an inc file
structure? Thanks in advance. - CES
<%
Response.WriteFile("Yourfile.FileExtension");
%>
----- Yourfile.FileExtension ------
<div id="copyright">
Copyright <%=DateTime.Now.Year.ToString()%> - <%=MyWebSite%> - All rights
reserved.
<br />Use of this site signifies the users complete agreement to all terms,
contained
<br />&amp; described within the Terms of Use page (Updated July 31, 2008)
</div>


Reply With Quote
  #2  
Old 08-27-2008, 11:29 PM
Cowboy \(Gregory A. Beamer\)
Guest
 
Default Re: Executing a var within an aspx .inc file?

Why create include files in ASPX. It is much easier to derive from the Page
class and have your pages derive from that class. You can then have
something the same in every page that needs it.

There are other ways to set up global FUD, of course. I am not sure #Include
is my first option. It is probably my last.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think outside the box! |
********************************************
"CES" <ces@noemaill.com> wrote in message
news:OmJTPSLCJHA.1224@TK2MSFTNGP02.phx.gbl...
> All,
> How do you write out a variable in a ASPX .inc?? I've used the following
> in my code and it worked until I changed the date & MyWebSite, to a server
> side write... is there any way of getting this to work within an inc file
> structure? Thanks in advance. - CES
> <%
> Response.WriteFile("Yourfile.FileExtension");
> %>
> ----- Yourfile.FileExtension ------
> <div id="copyright">
> Copyright <%=DateTime.Now.Year.ToString()%> - <%=MyWebSite%> - All rights
> reserved.
> <br />Use of this site signifies the users complete agreement to all
> terms, contained
> <br />&amp; described within the Terms of Use page (Updated July 31, 2008)
> </div>
>
>


Reply With Quote
  #3  
Old 08-28-2008, 12:09 AM
CES
Guest
 
Default Re: Executing a var within an aspx .inc file?

Thanks for not answering my question... I'm just switch over to .net from
classic asp and as much as possible I'm trying to take small steps with
concepts I've used in the past and what you just stated doesn't mean
anything to me... yet!


"Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@comcast.netNoSpamM> wrote in
message news:eeizM5LCJHA.4884@TK2MSFTNGP02.phx.gbl...
> Why create include files in ASPX. It is much easier to derive from the
> Page class and have your pages derive from that class. You can then have
> something the same in every page that needs it.
>
> There are other ways to set up global FUD, of course. I am not sure
> #Include is my first option. It is probably my last.
>
> --
> Gregory A. Beamer
> MVP, MCP: +I, SE, SD, DBA
>
> Subscribe to my blog
> http://feeds.feedburner.com/GregoryBeamer#
>
> or just read it:
> http://feeds.feedburner.com/GregoryBeamer
>
> ********************************************
> | Think outside the box! |
> ********************************************
> "CES" <ces@noemaill.com> wrote in message
> news:OmJTPSLCJHA.1224@TK2MSFTNGP02.phx.gbl...
>> All,
>> How do you write out a variable in a ASPX .inc?? I've used the following
>> in my code and it worked until I changed the date & MyWebSite, to a
>> server side write... is there any way of getting this to work within an
>> inc file structure? Thanks in advance. - CES
>> <%
>> Response.WriteFile("Yourfile.FileExtension");
>> %>
>> ----- Yourfile.FileExtension ------
>> <div id="copyright">
>> Copyright <%=DateTime.Now.Year.ToString()%> - <%=MyWebSite%> - All
>> rights reserved.
>> <br />Use of this site signifies the users complete agreement to all
>> terms, contained
>> <br />&amp; described within the Terms of Use page (Updated July 31,
>> 2008)
>> </div>
>>
>>

>

Reply With Quote
  #4  
Old 08-28-2008, 01:49 AM
Michael Starberg
Guest
 
Default Re: Executing a var within an aspx .inc file?

"CES" <ces@noemaill.com> wrote in message
news:%23MhTrPMCJHA.1628@TK2MSFTNGP03.phx.gbl...
> Thanks for not answering my question...


- I'd say he did.

> I'm just switch over to .net from classic asp and as much as possible I'm
> trying to take small steps with concepts I've used in the past


- Maybe that is your problem

> and what you just stated doesn't mean anything to me... yet!


- So it is Gregorys fault you don't understand? Hmm..

//Michael Starberg


Reply With Quote
  #5  
Old 09-02-2008, 11:17 AM
Cowboy \(Gregory A. Beamer\)
Guest
 
Default Re: Executing a var within an aspx .inc file?


"CES" <ces@noemaill.com> wrote in message
news:%23MhTrPMCJHA.1628@TK2MSFTNGP03.phx.gbl...
> Thanks for not answering my question...


I did answer your question. You did not give me a context to go from, so I
made an incorrect assumption.

>I'm just switch over to .net from classic asp and as much as possible I'm
>trying to take small steps with concepts I've used in the past and what you
>just stated doesn't mean anything to me... yet!


Now I have a context.

ASP is inline coded. It is interpreted one line at a time. ASP.NET is
compiled. This is your first paradigm shift.

You can do

<%
//code here
%>

in ASP.NET, but it is not advised. You are better to bind than to write out
stuff.

For example, you want a copyright date. Here is your old code:

<div id="copyright">
Copyright <%=DateTime.Now.Year.ToString()%> - <%=MyWebSite%> - All rights
reserved.
<br />Use of this site signifies the users complete agreement to all terms,
contained
<br />&amp; described within the Terms of Use page (Updated July 31, 2008)
</div>

To do this in .NET, you have three choices:

1. Use a class derived from page
2. Use a master page
3. User a control

The master page is probably the best option, if this is all you are doing,
but it is not something you can do to a page without altering it quite a
bit. With the class option, you can pull your ASP tags and with minor
alteration have the page running (it may not do everything the ASP does, but
it will display the copyright).

The user control encapsulates the logic, but you will have to drag it on
every page, which is why the master is so important.

Which of the options you ultimately chose depends on where you want to go.
The best replacement for .inc is a derived class. The best option, long
term, is a master page. If you feel you might use this in multiple sites, a
user control (or even a compiled server control) may be a better option.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think outside the box! |
********************************************

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 06:58 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.