|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Creating ASP code fragments 'on the fly'
Hi,
I'm trying to give my clients a bit of extra controll over their application by allowing them to modify parts of my ASP program using a code template. For example, on the landing page, the program displays a list of all current tasks in the user's ToDo list, but different clients may want to handle specific items in that list in different ways: e.g. Client 1 wants to highlight the oldest items in a different color. Client 2 may want to Alert. Client 3 wants to kick off a message through Email. Client 4 wants to force the user to attend to any messages older than 4 days. Rather than create a completely custom page for each client, I want to keep the original page exactly as is, but allow each client to configure additional code that will be inserted into the page on load. One way of doing this is to use Include pages, but I can't use this in this case because there may be several clients hosted on the same server, plus the clients would need FTP access to upload their own include files. I could also handle most situations in JavaScript, such that the ASP file just writes out the Script block as its loading, but there are some things that are only possible in ASP. I would prefer to handle this through a database entry which the client can make in their profile page, and then smack the code from the database into the ASP file as it's being requested. Is this possible, and if so, how? |
|
#2
|
|||
|
|||
|
---BEGIN QUOTE---
Is this possible, and if so, how? ---END QUOTE--- Well anything is possible, what you ask for is rather hard to explain, what I mean is that you can have/use many different approaches/techniques to achieve what you want. It would take too long to explain all possible scenario's One way of doing this is allowing the users to customize what they want. You then save these settings/customization into a database. Once the user logs in again, you retrieve these settings/customization from your database and display(or do whatever) them in the way it's suppose to be(hope that makes sense!) Now since we/I'm missing a lot of specs, I can't offer you more help. But you get the idea right! The including can also be a nice approach! hope this helps! Sincerely Vlince |
|
#3
|
|||
|
|||
|
VBS has a mechanism to build a code string and execute the string, maybe it will do what you want.
http://msdn.microsoft.com/library/d...sstmexecute.asp |
|
#4
|
|||
|
|||
|
Vlince: Yes, but other than trying to think of every possible thing that the all clients want and then switching that piece of code on/off according to a single client's settings is a near-impossible task.
Doug G: Yes, but again I think that the VBS method is entirely client-side. |
|
#5
|
||||
|
||||
|
So you want users to be able to enter asp code of their own devising, which is then executed on your server? I hope you have some sort of moderation/review before you allow the code to run, or you could be opening quite a security hole in your system.
As far as how to do it, I think Vlince's way is best. Unless your clients have specifically asked to be able to modify any arbitrary parts of your page, you don't need to give them that capability. Come up with a dozen useful modifications, or ask the clients for their top 5 requests, and just code those options. Giving complete control is perhaps possible, but it would be prohibitively difficult, and allow possible security breaches. For that reason, using a certain set of customizable preferences is a good idea. |
|
#6
|
|||
|
|||
|
No, for sure it's a big security problem in most situations, but this is for use in an Intranet-only situation - the app I've written is likely to be used by multiple departments for different things in the same company.
They have their own internal IT department, and it is hankering to create their own custom bits and bobs, but neither they nor I want them to be messing with the main code. So, the idea is to create entry points in the ASP into which their custom code can be inserted. I'm just trying to find a way to manage that insertion according to the user and department. I figure that the logical place to store the snippet is in a database keyed by user/department. Then when the page loads I can say, "At this point, insert the code from tblUserCodes for the current user." I can do this quite easilly using javascript (just by appending a javascript code block to the HTML stream), but as I said, there are some things (such as specific data requests) that can't be done that way. I could do something like this If DeparmentID = 1 then #Include Dep1.inc Elseif DeparmentID = 2 then #Include Dep2.inc etc.. But that forces me to use files, and it's clumsy for all kinds of reasons. As I understand it, the include directive gets processed before any scripting, so although the above would work, it would bloat the ASP. Also, it would be cumbersome to deal with a dynamic organisation structure. Last edited by SoaringTortoise : September 12th, 2003 at 03:27 PM. |
|
#7
|
||||
|
||||
|
The includes could be cumbersome, but the bloating/slowdown occurs mostly if the included file has many functions and variables that are not used by the script that does the including. If your include files only contain what you need, then performance is not harmed much.
If you can handle most of the customization using javascript, with just a few things that need to be done on the server side, I would say use the include files with logic (be sure to set that up right, http://www.microsoft.com/windows200...asp/iiwainc.htm shows how to do it) for the things that have to be asp, and for the rest use your javascript. |
|
#8
|
|||
|
|||
|
Well put. I am convinced. Thanks.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Creating ASP code fragments 'on the fly' |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|