berb0ne
asked on
Dynamic href thickbox
Hi Guys
I am using thickbox on ASP.NET 2.0 website
I am having problems dynamically changing href url after the page loads, I am using asp.net 2.0 page and currently using sqlquery to retrieve href url using Eval method.
When the page is loaded href is filled with url from databse which works fine, what i am trying to do is then manipulate href based on some conditions on the page.
What would be the best way to change href when the page is loaded? i am thinking about running code from vb page and the passing values to href. I can write vb function that will give me desired url but i am not sure how to pass the results to thickbox and change href value so when usr clicks on it it opens desired image
Any help will be greatly appreciated
Thank you
I am using thickbox on ASP.NET 2.0 website
I am having problems dynamically changing href url after the page loads, I am using asp.net 2.0 page and currently using sqlquery to retrieve href url using Eval method.
When the page is loaded href is filled with url from databse which works fine, what i am trying to do is then manipulate href based on some conditions on the page.
What would be the best way to change href when the page is loaded? i am thinking about running code from vb page and the passing values to href. I can write vb function that will give me desired url but i am not sure how to pass the results to thickbox and change href value so when usr clicks on it it opens desired image
Any help will be greatly appreciated
Thank you
ASKER
Codebot:
you can create your hyperlink as a label of type html.
then pass any value you want to this label
The problem being is that i need to work with a thickbox because of the website that i am working on, i need to have a pop-up window with an image, and thickbox fits well in that area.
Thanks anyway for sugestion
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for reply
That looks like something that could help, is there any elegent way of passing value from vb page to jquery script? (value=url) based on $("a#changeme").attr('href ','http://maps.google.com/'); example
That looks like something that could help, is there any elegent way of passing value from vb page to jquery script? (value=url) based on $("a#changeme").attr('href
yes you can use this javascript function to get value from url
var urlval = getQueryVariable('urlval ');
$("a#changeme").attr('href ',urlval );
var urlval = getQueryVariable('urlval ');
$("a#changeme").attr('href
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
}
ASKER
hi Codebot I am not entirely sure stil how i would pass the variable from vb code to javascript. Any tips?
ASKER
I had a litle play with $("a#changeme").attr('href ','http://maps.google.com/'); example,
It does change the href of a thickbox, however because i have multiple thickboxes (<a class=thickbox) on a page it changed the href for all of them. Is there a way of using javascript function to search through the thickboxes for a specific words for example "Pictures/Photo1" and then replace it with a different value ie "Pictures/Photo1.new") but only in a thickbox that contains Photo1 not Photo2,3 etc
Thanks
It does change the href of a thickbox, however because i have multiple thickboxes (<a class=thickbox) on a page it changed the href for all of them. Is there a way of using javascript function to search through the thickboxes for a specific words for example "Pictures/Photo1" and then replace it with a different value ie "Pictures/Photo1.new") but only in a thickbox that contains Photo1 not Photo2,3 etc
Thanks
Yes you can use replace function
http://www.w3schools.com/jsref/jsref_replace.asp
or
$(this).attr('href').repla ce('all',' something' );
http://www.w3schools.com/jsref/jsref_replace.asp
or
$(this).attr('href').repla
ASKER
Wasn't easiest to follow
then pass any value you want to this label