gpt4 book ai didi

.net - 带有 UpdatePanel 的 JQuery 工具工具提示

转载 作者:行者123 更新时间:2023-11-29 20:25:31 25 4
gpt4 key购买 nike

我的问题与在带有在 asp.net UpdatePanel 控件中刷新的工具提示的项目上使用 JQuery 工具工具提示插件 ( http://flowplayer.org/tools/tooltip.html ) 有关。问题在于,在添加工具提示后,来自 UpdatePanel 的任何部分回发都将导致工具提示在任何已更新的 UpdatePanel 中停止工作。在部分回发之前,工具提示效果很好。下面是我如何向页面上的图像(和其他控件)添加工具提示的示例。为简单起见,省略了一些代码:

<script type="text/javascript">
//--call this to add tooltips to any element with a class of "tooltipHandle"
function createTooltip(){

// select all desired input fields and attach tooltips to them
$(".tooltipHandle").tooltip({
// place tooltip on the right edge
position: ['center', 'right'],
// a little tweaking of the position
offset: [-2, 10],

// use a simple show/hide effect
effect: 'toggle',

// custom opacity setting
opacity: 0.7
});

}

//--add tooltips after every postback (including partial AJAX postbacks)
function pageLoad(sender, args) {
createTooltip();
}
</script>

<html>
<!-- assume this UpdatePanel is updated from the code behind--!>
<asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="upPanelPrivateMediaList">
<ContentTemplate>
<img class="tooltipHandle" src="/images/questionMark.gif"/>
<div class="tooltip">SOME GREAT TOOLTIP CONTENT</div>

</ContentTemplate>
</asp:UpdatePanel>

</html>

一件非常有趣的事情是,如果我在第一次加载页面时不调用“createToolTip()”,部分回发将正确地将工具提示添加到我的图像中,并且它将一直工作,直到我进行第二次回发。这意味着如果工具提示已经存在,部分回发只会处理工具提示。在部分回发后手动调用 createToolTip() 不会使工具提示再次工作。

如果您有任何想法或需要澄清,请告诉我。提前致谢!!

最佳答案

您可以将此代码粘贴到正文部分:

<script>
$(document).ready(function () {
$("#demo a[title]").tooltip();
});
</script>

将以下代码粘贴到 .cs 文件中:

protected void Page_Load(object sender, EventArgs e)
{
string javaScriptFunction =
"$(document).ready(function () {" +
"$('#demo a[title]').tooltip()" +
"});";
Page.ClientScript.RegisterStartupScript(typeof(Page), "ajaxTrigger", "Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);", true);
Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "EndRequest", "function EndRequestHandler(sender, args){" + javaScriptFunction + "}", true);
}

关于.net - 带有 UpdatePanel 的 JQuery 工具工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1380876/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com