473,886 Members | 2,373 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic Includes in ASP

46 New Member
Hi Everyone,

I have newly started as a ASP developer. I have been working on some change request and was blogged down with dynamic includes. Eventually I had managed to figure out the problem and find a solution. I am posting my findings for two purpose:

1) Help someone else who faces the same problem
2) Experts to point me to a better solution to the same porblem.


Problem: The are three different types of user to a system: Admin1, Admin2 and Admin3. All the three user are doing the same admin functionality - Add New user to the system but the admin add new user form should show different footers - footer1 for Admin1 and footer2 for admin2 and 3.

The admin type is determined by accounttype which is a session varible, so I tired the obvious solution

Expand|Select|Wrap|Line Numbers
  1.  
  2. <%If (Session(“accounttype”)=1)% Then>
  3. <!--#include file="footer1.asp" -->
  4. <%Else%>
  5. <!--#include file="footer1.asp" -->
  6. <%End If %>
  7.  
  8.  
The page kept throwing the followign error -
Microsoft VBScript runtime error '800a01f4'
Variable is undefined: 'SQLAccess'
footer1.asp, line 74

I tired, the same code with Response.Write and it was working fine. A simple google pointed me to an article explaining about Server Side Include and hence for the same reason I was not able to use the aboce code.

The actual Solution to the problem was thought to be:

Expand|Select|Wrap|Line Numbers
  1. <% Dim selectInclude
  2. selectInclude = Session("sccounttype")
  3.  
  4. Select Case selectInclude 
  5.  
  6. Case "99" %>
  7. <!-- #include file="footer1.asp" -->
  8.  
  9. <%Case "2"%>
  10. <!-- #include file="footer2.asp" --> 
  11.  
  12. <%Case "3"%>
  13. <!-- #include file="footer2.asp" --> 
  14.  
  15. <%End Select%>
  16.  
but again I got error -
Active Server Pages error 'ASP 0126'
Include file not found
createUser.asp, line 669
The include file 'footer2.asp' was not found.

I had no clue why it showed me this error as I was quite sure for the code to work but a little trying around - I figured the EXACT working code is:

Expand|Select|Wrap|Line Numbers
  1. <% Dim selectInclude
  2.  
  3. If Session("AccountType") = 1 Then 
  4. selectInclude = 1
  5. Else 
  6. selectInclude = 2
  7. End If
  8.  
  9. Select Case selectInclude 
  10.  
  11. Case "1" %>
  12. <!-- #include file="footer1.asp" -->
  13.  
  14. <%Case "2"%>
  15. <!-- #include file="footer2.asp" --> 
  16.  
  17. <%End Select%>
  18.  
  19.  
Questions from experts:
1) Though I have vague idea about why my second piece of code didn't work, I would request a clearer reasoning.
2) Is there any other better way of doing it?

Hope any looking for dynamic include finds it useful and I get more clearer about this concept.

Thanks and wishes
Sree
Jun 11 '07 #1
1 1577
jhardman
3,406 Recognized Expert Specialist
Sree,

First code should work fine besides that the % is in the wrong place:
Expand|Select|Wrap|Line Numbers
  1. <%
  2. If Session(“accounttype”)=1 Then %>
  3.    <!--#include file="footer1.asp" -->
  4. <%
  5. Else %>
  6.    <!--#include file="footer2.asp" -->
  7. <%
  8. End If %>
  9.  
The error code you showed does not appear to be related to this problem.

One thing that I have seen that causes the logic to fail in these cases is when the variable is supposed to be an integer but is actually a numeric string. In other words you need to distinguish between
Expand|Select|Wrap|Line Numbers
  1. session("accounttype")=1
and
Expand|Select|Wrap|Line Numbers
  1. session("accounttype")="1"
Does this make sense?

Jared
Jun 11 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2254
by: jason | last post by:
Will this work - dynamic determination of root (local or web host) and consume this in include file anywhere. I am concerned about dynamic construction of virtual absolute include in the consuming file. Take a look and tell me what you think: GLOBAL.ASA Sub application_onstart
0
2078
by: Pascal Costanza | last post by:
Dynamic Languages Day @ Vrije Universiteit Brussel ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Monday, February 13, 2006, VUB Campus Etterbeek The VUB (Programming Technology Lab, System and Software Engineering Lab), ULB (deComp) and the Belgian Association for Dynamic Languages (BADL) are very pleased to invite you to a whole day of presentations about the programming languages Self, Smalltalk and Common Lisp by experts in...
1
4839
by: Satish.Talyan | last post by:
hi, i want to create a dynamic tree hierarchy in javascript.there are two parts in tree, group & user.when we click on group then users come under that's tree category will be opened.problem is that i am not able to arrange three things simultaneously,group,users & there functionality simultaneously.dynamic means group & users come from database and groups & users can be increased in number at any time. i am sending code for that tree...
7
2490
by: Ajinkya | last post by:
I have writen a program for a game called game.exe Now it includes a player part to which has to be a function to be writen by someone else. Now I want to provide this exe to some tester who will be writing his player function. I dont know his file name and his function name....he will have to include it. I am providing him the game.exe and a common file containing all the
0
9957
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11172
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10770
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10873
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10430
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7988
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7141
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6010
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4632
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.