Solved

Dynamic href thickbox

Posted on 2010-11-23
9
1,047 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
  • 5
  • 4
9 Comments
 
LVL 6

Expert Comment

by:Codebot
Comment Utility
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
Comment Utility
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 500 total points
Comment Utility
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
 

Author Comment

by:berb0ne
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 6

Expert Comment

by:Codebot
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Wasn't easiest to follow
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now