Click here to Skip to main content
15,881,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Updated 1-Feb-13 6:30am
v2
Comments
[no name] 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.
[no name] 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900