简体   繁体   English

带FancyBox内联html的ASP.NET中继器

[英]ASP.NET Repeater with FancyBox Inline html

I'm trying to have a repeater which shows items from a database, and then a modify button at the end which opens up a modify form in a fancy box. 我正在尝试使用一个中继器来显示数据库中的项目,然后在末尾显示一个“修改”按钮,以在一个精美的框中打开一个修改表单。 I am able to make inline HTML appear in a fancybox just fine following the tutorials from the website. 按照网站上的教程,我可以使内联HTML出现在fancybox中。 However, the issue is when I try to do this within a .net repeater. 但是,问题是当我尝试在.net中继器中执行此操作时。

<asp:Repeater ID="ModifyRepeater" runat="server">
    <ItemTemplate>

    <a class="modify" href="#fancy_<%#Eval("ID")%>">Modify</a>

    <div style="display:none">
       <div id="#fancy_<%#Eval("ID")%>">Some content here</div>
    </div>

    </ItemTemplate>
</asp:Repeater>

Javascript: Javascript:

$(document).ready(function () {
    $(".modify").fancybox(); 
});

When I load the page, I can see the content divs are created with the correct ID's, and the HREFS on the links are pointing to the correct ID as well. 当我加载页面时,我可以看到内容div是使用正确的ID创建的,链接上的HREFS也指向正确的ID。

When I click the button to modify, it just reloads the entire page inside the fancybox. 当我单击按钮进行修改时,它只是将整个页面重新加载到了花式框内。

In the console, I will see it says "Uncaught TypeError: Canot call method 'width' of undefined 在控制台中,我将看到“未捕获的TypeError:未定义的Canot调用方法'width'

Thanks to Xander, I mistakenly added the extra # in the ID field of the div. 感谢Xander,我错误地在div的ID字段中添加了额外的#。 Removing this fixed it cheers! 删除此固定它欢呼!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM