Solved

Dynamic href thickbox

Posted on 2010-11-23
9
1,053 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 500 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
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!

 

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

Technology Partners: 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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

763 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