Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Aug 25, 2010 07:51 AM by ignatandrei
Member
311 Points
328 Posts
Aug 24, 2010 09:30 PM|LINK
Hello
I 'm gonna query database for photo records. each record include "photo path" where imagesURL stored in string format
I Choses my favorite Juqery plugin to show images. Plugin needs some lines of code like below.
How could I generate these lines
<script> $(function() { $('#slideshow').crossSlide({ sleep: 2, fade: 1 }, [ { src: 'picture1.jpg' }, { src: 'picture2.jpg' }, ...... ..... { src: 'picture4.jpg' } ]) }); </script>
All-Star
134491 Points
21566 Posts
Moderator
MVP
Aug 25, 2010 07:51 AM|LINK
Solution 1:
in code behind :
public string GenerateJS(){
string ret="";
foreach( var str in <your picture collection>){ ret+= "
{ src: '" + str + "' }";
}
return ret;
In aspx page
<script> $(function() { $('#slideshow').crossSlide({ sleep: 2, fade: 1 }, [ <% = GenerateJS() %> ]) });</script>Solution 2:http://msdn.microsoft.com/en-us/library/system.web.ui.page.registerstartupscript%28VS.71%29.aspx
<script> $(function() { $('#slideshow').crossSlide({ sleep: 2, fade: 1 }, [ <% =
]) });</script>Solution 2:
s2002
Member
311 Points
328 Posts
Use DB query result to generate Jquery required lines of code
Aug 24, 2010 09:30 PM|LINK
Hello
I 'm gonna query database for photo records. each record include "photo path" where imagesURL stored in string format
I Choses my favorite Juqery plugin to show images. Plugin needs some lines of code like below.
How could I generate these lines
ignatandrei
All-Star
134491 Points
21566 Posts
Moderator
MVP
Re: Use DB query result to generate Jquery required lines of code
Aug 25, 2010 07:51 AM|LINK
Solution 1:
in code behind :
public string GenerateJS(){
string ret="";
foreach( var str in <your picture collection>){
ret+= "
{ src: '" + str + "' }";}
return ret;
}
In aspx page