?
Solved

Dynamic href thickbox

Posted on 2010-11-23
9
Medium Priority
?
1,059 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
Independent Software Vendors: 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!

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

764 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