【发布时间】:2013-06-30 09:05:58
【问题描述】:
我在我的代码隐藏中存储了几个值作为 via Request.QueryString,如下所示:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
lblRow.Text = Request.QueryString["num"];
string Image1 = Request.QueryString["ImageAlt1"];
string Image2 = Request.QueryString["ImageAlt2"];
string Image3 = Request.QueryString["ImageAlt3"];
}
}
然后我尝试在我的 jquery 中调用这些值,我得到一个 does not exist in current context 错误这是我的 jquery
$("#fancybox-manual-c").click(function () {
$.fancybox.open([
{
href: "<%= Image1 %>",
title: 'My title'
}, {
href: '<%= Image2 %>',
title: '2nd title'
}, {
href: '<%= Image3 %>'
}
], {
helpers: {
thumbs: {
width: 75,
height: 50
}
}
});
});
我不确定我做错了什么。我唯一的猜测是在获取变量之前调用了 jquery,因为它应该被设置。
这是我调用其余项目的表单视图:
<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource3"
DataKeyNames="num">
<ItemTemplate>
<asp:Label ID="ItemType_Label" runat="server" Text='<%# Bind("ItemName") %>' />
<br />
<asp:Label ID="ItemDescription_Label" runat="server" Text='<%# Bind("ItemDescription") %>' />
<br />
<b>Asking Price:</b>
<asp:Label ID="ItemPrice_Label" runat="server" Text='<%# Bind("ItemPrice") %>' />
<br />
<ul>
<li><a id="fancybox-manual-c" href="javascript:;">Open gallery</a></li>
</ul>
</ItemTemplate>
</asp:FormView>
【问题讨论】: