Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Dynamic href thickbox

Posted on 2010-11-23
9
Medium Priority
?
1,061 Views
Last Modified: 2012-05-10
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
0
Comment
Question by:berb0ne
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 6

Expert Comment

by:Codebot
ID: 34196342
you can create your hyperlink as  a label of type html.
then pass any value you want to this label
0
 

Author Comment

by:berb0ne
ID: 34196446
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
0
 
LVL 6

Accepted Solution

by:
Codebot earned 1500 total points
ID: 34196639
Then you can use jquery to search and replace your hyperlink

$("a#changeme").attr('href','http://maps.google.com/');

http://stackoverflow.com/questions/179713/how-to-change-the-href-for-a-hyperlink-using-jquery
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:berb0ne
ID: 34196716
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
0
 
LVL 6

Expert Comment

by:Codebot
ID: 34196909
yes you can use this javascript function to get value from url
var urlval = getQueryVariable('urlval ');
$("a#changeme").attr('href',urlval );

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]; 
} 
} 
} 

Open in new window

0
 

Author Comment

by:berb0ne
ID: 34197861
hi Codebot I am not entirely sure stil how i would pass the variable from vb code to javascript. Any tips?
0
 

Author Comment

by:berb0ne
ID: 34198084
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
0
 
LVL 6

Expert Comment

by:Codebot
ID: 34203359
Yes you can use replace function

http://www.w3schools.com/jsref/jsref_replace.asp
or
$(this).attr('href').replace('all','something');
0
 

Author Closing Comment

by:berb0ne
ID: 34203924
Wasn't easiest to follow
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question