ASP.NET question

  • Thread starter Thread starter John Salerno
  • Start date Start date
J

John Salerno

Is there a separate ASP.NET newsgroup? I can't find one, and I don't
know if it's appropriate here, but I figure it's still written in C# so
it's all the same thing anyway.

I'm just wondering how I might write something that inserts a "Home"
icon wherever I put the code. In other words, instead of putting a
separate icon on each page, so that I'd have to change them all if I
wanted a different icon, is there a way to make one 'file' or 'link' or
whatever you'd call it that I can put on my page, and I just change one
thing to change the image? I'm guessing I could use ASP.NET for this,
but I have no experience with it so I'm not too sure what it even does.
I'm only familiar with Windows programming so far.
 
...
Is there a separate ASP.NET newsgroup?
I can't find one, and I don't know if it's appropriate
here, but I figure it's still written in C# so it's all the same thing
anyway.

Well, both yes and no.

I think this particular question rather belongs to a more specific ASP.NET
group, or possibly even an even more generic one.

To give an example:

microsoft.public.dotnet.framework.aspnet

.... ;-)

I'm just wondering how I might write something that inserts a "Home" icon
wherever I put the code. In other words, instead of putting a separate
icon on each page, so that I'd have to change them all if I wanted a
different icon, is there a way to make one 'file' or 'link' or whatever
you'd call it that I can put on my page, and I just change one thing to
change the image? I'm guessing I could use ASP.NET for this, but I have no
experience with it so I'm not too sure what it even does. I'm only
familiar with Windows programming so far.

I don't even see this as an ASP.NET question, but rather an SSI question
(Server-Side Includes), which isn't confined to only ASP.NET, but works on
rather many webservers, not only IIS.

An example on what you can put into the pages (in "HTML-mode"):

<!--#include file="homelink.inc"-->

Then you can simply change the contents of that file when you need to, e.g.:

In homelink.inc:

<a href="default.aspx"><img alt="Home" src="home.gif"></a>


// Bjorn A
 
Bjorn suggest a very easy solution that might work for you, but you still
need to have that line inserted in every page. The object way would be to
create a user control and add that to each page through some form of master
page template - much easier with .net 2.0.

As an alternative, look at ihttpmodules and insert the link in the page as
the response is pipelined to the browser, that way you dont insert it
anywhere manually and the runtime adds it at delivery time.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 
Bjorn Abelli wrote:
is as an ASP.NET question, but rather an SSI question
(Server-Side Includes), which isn't confined to only ASP.NET, but works on
rather many webservers, not only IIS.

An example on what you can put into the pages (in "HTML-mode"):

<!--#include file="homelink.inc"-->

Then you can simply change the contents of that file when you need to, e.g.:

In homelink.inc:

<a href="default.aspx"><img alt="Home" src="home.gif"></a>

Yeah, I wasn't sure if ASP.NET would really do this kind of thing
anyway. SSI and CSS were both suggested to me, but I have no experience
with SSI. I thought I might try it in PHP, but that's when I figured I
could use ASP.NET as well.

But as far as SSI goes, all I have to do is include that line? And what
exactly goes in that file? I've never seen an .inc extension. Could it
be any extension, such as a gif for the image I want to use?
 
Never give an include file a .inc extension, give it an .asp extension. A
file with a .inc extension will render like a text file in your browser
exposing the code if it were called directly.
 
...
Bjorn Abelli wrote:
is as an ASP.NET question, but rather an SSI question

Yeah, I wasn't sure if ASP.NET would really do this kind of thing anyway.
SSI and CSS were both suggested to me, but I have no experience with SSI.
I thought I might try it in PHP, but that's when I figured I could use
ASP.NET as well.

But as far as SSI goes, all I have to do is include that line?
Yes.

And what exactly goes in that file?

Something that otherwise would have gotten into your HTML- or ASPX-file.

If it's something that you frequently use in many pages, it's a good idea to
have it in a separate file to make updates on, instead of the need to update
all pages where that particular code goes. In my example it contained only
one single line:

I've never seen an .inc extension. Could it be any extension, such as a
gif for the image I want to use?

Nope. It need to be text, as I illustrated above.

But as another poster suggested, it could be a good idea to *not* use ".inc"
as extension, use .asp or .aspx, depending on how you intended to include
the "homelink" in the first place.

<!--#include file="homelink.asp"-->


// Bjorn A
 
...
Never give an include file a .inc extension, give it an .asp
extension. A file with a .inc extension will render like a
text file in your browser exposing the code if it were called directly.

If it's code that otherwise would go into an asp- or aspx-page, I agree.

But if it's plain HTML, I personally like to use an extension easily
separated from other extensions.

Such content will be exposed to the browser anyway...

// Bjorn A
 
Bjorn said:
...




Something that otherwise would have gotten into your HTML- or ASPX-file.

If it's something that you frequently use in many pages, it's a good idea to
have it in a separate file to make updates on, instead of the need to update
all pages where that particular code goes. In my example it contained only
one single line:




Nope. It need to be text, as I illustrated above.

Actually, I meant could I use it to display a gif, like your example
did, which I should have noticed earlier!
 
Back
Top