Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET C#4.0 jQuery
How to dynamically bind fancybox to image button from code behind in page load, using register startup script,type iframe and the fancy box should display the url i passed to it, how can i achieve this
 
i have to navigate to the requested url in fancybox in imagebutton clientclick,
so i want to register clientscript in page load code behind
 
actually i have to show websites[another domain] in fancybox based on images clicked
 
i want all the bindings to be done in page load code behind since some sites are restricted, I would check database for user permissions and allow/deny site access
 
the site is shown in fancy box iframe
 
thanks,
 
This is my code:
 
string strscript = "@<script type='text/javascript'>$(document).ready(function(){$('#" + imgBtnID.ID + "').fancybox({'type': 'iframe','width':" + _strWidth + ",'height': " + _strHeight + ",'href':'" + _strURL + "'})});</script>"; ClientScript.RegisterStartupScript(typeof(ImageButton), "script_" + imgBtnID.ID, strscript, false); 
Posted 1-Feb-13 2:36am
Edited 1-Feb-13 6:30am
34K
v2
Comments
shabarnadh.vempati at 1-Feb-13 8:37am
   
string strscript = "@<script type='text/javascript'>$(document).ready(function(){$('#" + imgBtnID.ID + "').fancybox({'type': 'iframe','width':" + _strWidth + ",'height': " + _strHeight + ",'href':'" + _strURL + "'})});</script>";
ClientScript.RegisterStartupScript(typeof(ImageButton), "script_" + imgBtnID.ID, strscript, false);
 
this is my code
Irbaz Haider Hashmi at 1-Feb-13 13:01pm
   
Add the javascript on page and bind the function from code dynamically
 
ImageButton1.Attributes.Add("onclick", "youfunction('"+ImageButton1.ClientID+"',"+strwidth+","+strheight+");");
 

this is how you can pass the parameters to the function.
shabarnadh.vempati at 2-Feb-13 0:09am
   
ThanQ,,,,,But How can I use href here,,,>>>>?
Irbaz Haider Hashmi at 2-Feb-13 3:45am
   
Pass that as a variable too.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 210
1 Richard MacCutchan 100
2 kbrandwijk 90
3 ProgramFOX 80
4 Mukesh Bhagat 65
0 Sergey Alexandrovich Kryukov 9,050
1 OriginalGriff 8,151
2 CPallini 2,613
3 Richard MacCutchan 2,221
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 1 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100