我已经开始变量,并宣布他们为什么我的C#变量在Jquery中返回null?
protected string Image1;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string Image1 = Request.QueryString["ImageAlt1"];
}
}
我已要求从jQuery的变量正常,当我测试链接我什么也没得到
$("#fancybox-manual-c").click(function() {
$.fancybox.open([
{
href: '<%=Image1%>',/*returns '' instead of 'path/image.jpg'*/
title: 'My title'
}
], {
helpers: {
thumbs: {
width: 75,
height: 50
}
}
});
我想通了,我放在<%=Image1%>
javascript内部返回null,因为当我从href
属性中删除所有值时,我得到了同样的错误。
href:'' /*causes the jquery not to fire when the link is clicked*/
最后,我测试,看看是否Request.QueryString
返航空,因此我放置在标签
lblImage1.Text = Image1; //returns 'path/image.jpg'
和路径张贴在标签图像的image1
值。为什么jQuery中的变量为空?我错过了什么?
您需要ReSharper - 它会警告您通过在Page_Load中定义一个新变量来隐藏受保护的Image1。 –