Click here to Skip to main content
12,243,333 members (38,613 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# 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 3:36am
PBGuy1.8K
Edited 1-Feb-13 7:30am
v2
Comments
shabarnadh.vempati 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 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 2-Feb-13 0:09am
   
ThanQ,,,,,But How can I use href here,,,>>>>?
Irbaz Haider Hashmi 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160426.1 | Last Updated 1 Feb 2013
Copyright © CodeProject, 1999-2016
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