我在我的代码隐藏中存储了几个值,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>