PDA

View Full Version : Passing server side variables to Simple Controls Gallery v1.3



Hyporea
07-14-2010, 05:17 PM
1) Script Title: Simple Controls Gallery v1.3

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/simplegallery.htm

3) Describe problem: Passing path/filename data from server side ASP to Simple Controls Gallery.

Firstly, I am impressed with the Simple Controls Gallery and currently I am working to integrate it into an ASP classic site (will eventually migrate to ASP.NET). The challenge is that the site would use Simple Controls Gallery to display images from various user accounts from a database. I need a way to pass the image's filename (including the path) which is queried from a database to Simple Controls Gallery.

Is there a simple way to feed these server side values to the controls' imagearray? At this moment only the element for the filename is needed, none of the optional elements are required.

I am currently trying to work this out myself, but I'm at a point where I need to ask for help/guidance. Any would be appreciated.

Thanks in advance!

--Andre

djr33
07-14-2010, 05:31 PM
Since I use PHP, not ASP, and I'm not particularly familiar with this, my response may not be very helpful, but I can at least give you an idea:

You should create a new javascript tag in your html then within that use ASP to generate some values.

Here's an example using PHP:

<script type="text/Javascript">
var myvar = '<?php print $myvar; ?>';
</script>

Then within all Javascripts operating on that page you can use 'myvar' to get the values.

Note that you could also do this directly such as printing a value from ASP into the setup for the script, but since that may be external or just complex to setup, this might be easier. Then once you have "myvar", just use that as the value in your script:
var somesetting = myvar;

Hyporea
07-14-2010, 05:52 PM
You should create a new javascript tag in your html then within that use ASP to generate some values.

Here's an example using PHP:

<script type="text/Javascript">
var myvar = '<?php print $myvar; ?>';
</script>




Hello djr33,

This is exactly the approach I am currently doing right now. ASP works the same way. I'm hoping for a more streamlined solution if possible. But if not, well, you know, I'll have to make due with what I can, which would be this.

The only thing I worry about using this approach is the maximum length of the variable. After querying the filenames from the database, path information will be included, which can easily be 100 characters per image. Since there might be one image or 100 images (or more), that's going to be a fairly long string to pass.

But since you also mention the same approach I was thinking, it does give me encouragement that I should prototype that. :-)

--Andre

Hyporea
07-15-2010, 05:09 PM
Update,

The method described by djr33 works, and works well. It took me some effort to manipulate the file path string coming from the database and formatting it with the [ ] that the Simple Controls Gallery likes, joined all the array elements into one variable, and passed that variable to JavaScript in the way djr33 described and success!

Thanks!

--Andre