Making functions available to both client and server side 
Author Message
 Making functions available to both client and server side

I have several utility functions which both my client and server scripts
need to use.  Is there a way I can declare them such that they are
accessible to both?  I was trying to work it with include files, but the
requirement of having <% %> around them for server side killed that idea.
Currently I have two include files (functions_client.inc and
functions_server.inc) which are exact copies of one another except for the
<% %> in the server file.  It works, but I hate it as I now have to update
my code in both places.

Any suggestions?

Thanks,

-Scott



Thu, 06 Feb 2003 03:00:00 GMT  
 Making functions available to both client and server side
IIS5/ASP3 solves the problem by supporting

<script language="VBScript" runat="server" src="functions.inc"></script>

For IIS4/ASP2, you can use an include for the server side (with the <%...%> delimiters).  To use the
same .inc file for the client, you read the .inc file (using FSO on the server side) into a
variable, strip the <%...%> delimiters, replacing them with client side <script language="vbscript">
and </script> tags respectively, and then Response.write the results back to the client.

It may be ugly, but it works ;-)...

--
Michael Harris
Microsoft.MVP.Scripting
--

Quote:
> I have several utility functions which both my client and server scripts
> need to use.  Is there a way I can declare them such that they are
> accessible to both?  I was trying to work it with include files, but the
> requirement of having <% %> around them for server side killed that idea.
> Currently I have two include files (functions_client.inc and
> functions_server.inc) which are exact copies of one another except for the
> <% %> in the server file.  It works, but I hate it as I now have to update
> my code in both places.

> Any suggestions?

> Thanks,

> -Scott



Thu, 06 Feb 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Calling client-side javascript function from server-side vbscript

2. Calling server-side function from client-side

3. attached Contact Item on server-side becomes attached Mail Item on client-side

4. How Can I Pass Data Between the Server Side and the Client Side VB/JScript

5. Server side or client side cursors?

6. Printing report at the client side and the report is at the server side

7. Printing report at the client side and the report is at the server side

8. Mixing of client-side and server-side scripts

9. Server side variables to client side script?

10. Server-Side vs Client-Side script

11. Using Server side Vs OnClick Client side

12. Client Side + Server Side Scripts

 

 
Powered by phpBB® Forum Software