【发布时间】:2016-01-21 07:07:04
【问题描述】:
在我使用 C# 的 asp.net 项目中,我需要从后面的代码中调用 JQuery 函数。 以下是包含所需脚本的函数:
<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();
}
以及我从 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);
}
当我使用输入按钮从客户端调用函数时它工作正常,但是当我从服务器端调用它时它不会调用 newform.aspx(当我从 showFancy 函数取消注释“alert(url);”时,警报作品)。我相信我称之为“新形式”的方式存在一个问题。提前感谢您的时间和回答。
【问题讨论】:
标签: javascript c# jquery asp.net ajax