|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
inserting a querystring variable into <!--include--> URL parth.. kinda tricky?
This is not working
Code:
activelang=Request.QueryString("lang")
.
some code
.
Response.Write " <!--#include virtual='/SIFS/" & activelang & "/welcome.txt' -->"
this is not working too... Code:
activelang=Request.QueryString("lang")
.
some code
.
<!--#include virtual='/SIFS/<%= activelang %>/welcome.txt' -->
Is there any trick will do the job ? Thanks for any replies...
__________________
Sweet smell of a great sorrow lies over the land. Plumes of smoke rise, merge into the leaden sky. A man lies and dreams of green fields and rivers, but awakes to a morning with no reason for waking. He's haunted by the memory of lost paradise. In his youth or dream, he can't be precise. He's chained forever to a world that's departed. It's not enough, it's not enough. Gilmour |
|
#2
|
|||
|
|||
|
I think the problem is that all the include files are processed first then all the code is executed. So I bet that your include is just being writtten to the html document and is not being processed.
I did some quick research and came up with an idea for you. I've never tried this and it only works in ASP 3.0 but I think you need to use the Response.Execute() function. If I understand correctly <!-- #include... --> is the old way of doing things. You should now be using Response.Execute() to use include files. I've never used the Execute method or tried to create dynamic inlcude files but here is my stab at it anyway. Code:
activelang=Request.QueryString("lang")
.
some code
.
Response.Execute("/SIFS/" & activelang & "/welcome.txt")
|
|
#3
|
|||
|
|||
|
Thanks a million for your time defjam
![]() I will try. If it doesn't works, I will have to do it the hard way: Code:
If activelang="jp" then <!--include this--> elseif activelang="en" then <!--include that--> End if etc.. ![]() |
|
#4
|
|||
|
|||
|
If your going to have more than 2 options a select case may be a better option. Another plus is that I find it easier to update.
Code:
activelang=lCase(Request.QueryString("lang")) 'convert to lower case
Select Case activelang
Case "jp"
<!-- #include... -->
Case "en"
<!-- #include... -->
Case "blah"
<!-- #include... -->
Case "gibberish"
<!-- #include... -->
Case Else 'default
<!-- #include... -->
End Select
|
|
#5
|
|||
|
|||
|
Done!
It is working. But with one little difference. It is not Response.Execute but Server.Execute ![]() Thanks. |
|
#6
|
|||
|
|||
|
Update:
Server.Execute is little different. It won't include any variable from the original page. I mean: Code:
page1.asp
name="Burak"
Server.Execute("page2.asp")
---------------
page2.asp
Response.Write name
This code will return "" because page2.asp will be executed in itself while <!--include--> can recognize all variables in original page. I can actually send a querystring like Server.Execute("page2.asp?name=Burak") but I am getting 'invalid URL' error. According to microsoft, this is a known bug and will be fixed. Just FYI... |
|
#7
|
|||
|
|||
|
Word of caution
I wouldn't recommend having a querysting variable alone be inserted into the include statement. I think your just opening up a can of worms security wise allowing users to include any file they want via the querystring. I know your thinking security through obscurity and all that but still its not a good idea. The PHP forum has a list thread about security notes for programming with php, which are general hints for being safe, and most of them apply to asp as well. It maybe be good for you to read that article. It really makes you think. Also, at the very least, do some sort of verification that the the activelang variable does hold values that you expect. Either a regular expression, or a case statement. At least this way it isn't open ended.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > inserting a querystring variable into <!--include--> URL parth.. kinda tricky? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|