Jump to content

Content (include file) changed by link click


022012

Recommended Posts

Okay... hope someone out there can help. Not to sure if it can be done through asp, but here it goes. What I'm trying do:I've got an asp file that is being used kind of like a template. The main section is another file that was pulled in using <!-- include file --> to lay it over a background from the template. All looks great at this point... the next step is changing the content in that main section of the content by a link click - so when you click on a link within that included file it removes the include file that's there and includes a different file in that section.Any ideas. Any help would be greatly appreciated

Link to comment
Share on other sites

I think i understood you, Within your .inc file, i believe you can use ASP. If you can, you can use the 'if - else' function.Its really easy. you will need to utilize querystrings also. When you create a link using HTML, write a querystring like this:www.domain.com/file.asp?action=resultThe question mark indicates the beginning of a querystring, the "action" word is the querystring name, and the result is the names value.When im using querystrings to preform an action on a subsequent page, i always use the name "action".The next thing you need to do it edit your .inc file. Within the .inc file, you need to recall your querystring in a if statement. The IF statement will display a peice of code, if the condition is true. other wise it will display a different peice of code:

<% if request.querystring("action")="step_one" then%>step oneYour homepage text can go here, in normal, standard HTMLThis will be displayed if the querystring name "action"'s value is equil to "step_one"<% else %>This will be displayed if the value of "action" is anything other than "step_one".<%end if%>

So, if i access that code above with the querystring: action=step_onethen it will display the text "Your homepage text can go here..." if the querystring is this:action=step_twothen it will display the text "this will be displayed if the value of "action" is anything other than..."So, this is what your end .inc file should look like:

<% if request.querystring("action")="example1" then %>Example One<a href="http://www.exampledomain.com/index.asp?action=example2">Example two link</a> <a href="http://www.exampledomain.com/index.asp?action=example3">Example three link</a><% else if request.querystring("action")="example2" then %>Example Two<a href="http://www.exampledomain.com/index.asp?action=example1">Example one link</a> <a href="http://www.exampledomain.com/index.asp?action=example3">Example three link</a><% else if request.querystring("action")="example3" then %>Example Three<a href="http://www.exampledomain.com/index.asp?action=example1">Example one link</a> <a href="http://www.exampledomain.com/index.asp?action=example2">Example two link</a><% end ifend ifend if%>

Using that code, you only need to use one .inc file, which is alot easier to update.IF you want to use a different .inc file for each page, you can use the following code:

index.asp file:<!-- CONTENT START --><% header=request.querystring("header")%><!--#include virtual="<%=header%>"--><!-- CONTENT END -->

Thats your index.asp file. Basically, your index.asp file should have the following querystring attached:index.asp?header=virtual pathThe virtual path is something like: /inc/homepage.incor /inc/page_two.inctherefore, if you wanted to display the homepage inc file, use the querystring:index.asp?header=/inc/homepage.incWithin the ASP file i have included a small script which will change the querystring value into a variable. the variable is called header. The <!--#include virtual="<%=header%>"--> then includes the inc file wrote in the variable. If you want to request a different page, you need to use the follow links:www.yourwebsite.com/index.asp?header=/inc/homepage.incwww.yourwebsite.com/index.asp?header=/inc/page_two.incwww.yourwebsite.com/index.asp?header=/inc/page_three.incwww.yourwebsite.com/index.asp?header=/inc/page_four.incSorry if this is confusing, if you need more help, ill try explain it more clearly

Link to comment
Share on other sites

I find it easier to do this:

<%   dim x   x=request.queryString("x")%>

And this when it's needed in the page:

<%if x="blah"%>   BLAH<%elseif x=null or x=empty%>   BLAH<%else%>   BLAH<%end if%>

I don't mean to be mean, but it hurts my hand if I type to much, so I thought other people might benifit from this.P.S. - So that's what <!--#include virtual=""--> does! I usually just do <!--#include file="include.inc"-->. Looks like I'll be using it in the future.And for safety reasons, 022012, you might want to use the Post method so people can't steal your stuff.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...