Solved

Dynamic href thickbox

Posted on 2010-11-23
9
1,057 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Suggested Courses

734 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