In my asp.net project with C#, I need to call a JQuery function from code behind. Below is the function include the required script:
<link rel="stylesheet" href="/fancybox/jquery.fancybox-1.3.4.css" type="text/css" media="screen" />
function showFancy(url, title, width, height) {
//alert(url);
$(".fancyBox").fancybox({
'width': width,
'height': height,
'autoScale': true,
'transitionIn': 'elastic',
'transitionOut': 'none',
'type': 'iframe',
'overlayColor': '#000000',
'overlayOpacity': 0.7,
'position': 'fixed',
'scrolling': 'yes',
'modal': false,
'target': "_parent",
"onClosed": function () {
window.location = window.location;
}
});
$('.fancyBox').attr({ href: url, title: title });
$('.fancyBox').click();
}
and the way I call from aspx.cs :
protected void Button1_Click(object sender, EventArgs e)
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "Script", "showFancy('NewForm.aspx?ordernumber2=' + $('#TxtContractNumber').val(), 'Send', '55%', '65%');", true);
}
It works fine when I call function from client side using an input button but when I call it from server side It doesn't call the newform.aspx (when I Uncomment "alert(url);" from showFancy function, alert works) . I believe there is one issue for the way I call 'newform'. Thanks in advance for your time and answer.