gpt4 book ai didi

c# - 单击按钮后回发后如何显示 div?

转载 作者:行者123 更新时间:2023-11-30 18:30:25 24 4
gpt4 key购买 nike

这里我有一个 div,我在母版页中鼠标悬停期间显示它,鼠标悬停后三个 href 链接将出现在该 div 中。单击该 href 链接后,它遍历到另一个页面,回发发生并且该 div 隐藏在母版页中。我还需要在单击后显示该 div。我使用了 updatepanel 并尝试了它,但它仍然无法正常工作。这是我的代码

//分区部分

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="Update" runat="server">
<ContentTemplate>
<div runat="server" class="divSUBMenu" id="describe" style="width: 700px; height: 20px;
font: Arial, Helvetica, sans-serif;" onclick="show(0)">
</div>
</ContentTemplate>
</asp:UpdatePanel>

//悬停部分

 <a href="#" onmouseover="showit(0)">
<img src="Images/Analyze_over.jpg" name="image1" width="84" height="22" border="0"
id="image1" alt="" /></a>

//用于鼠标悬停的 Javascript(工作正常)

var submenu = new Array();
submenu[0] = '&nbsp;<font style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"><a style="color: #FFFFFF; text-decoration: none;" href="ATrendAnalysis.aspx">Trend Analysis</a> &nbsp;&nbsp; <a style="color: #FFFFFF; text-decoration: none;" href="AEventPerformance.aspx">Event Performance</a> &nbsp;&nbsp; <a style="color: #FFFFFF; text-decoration: none;" href="ACannibalization.aspx">Cannibalization</a> &nbsp;&nbsp; <a style="color: #FFFFFF; text-decoration: none;" href="AHaloEffect.aspx">Halo Effect</a> &nbsp;&nbsp; <a style="color: #FFFFFF; text-decoration: none;" href="AVolumeDecomposition.aspx">Volume Decomposition</a></font></span>';
var delay_hide = 500;
var menuobj = document.getElementById ? document.getElementById("describe") : document.all ? document.all.describe : document.layers ? document.dep1.document.dep2 : "";

function showit(which) {
clear_delayhide();
document.getElementById("describe").style.visibility = 'visible';
thecontent = (which == -1) ? "" : submenu[which];
if (document.getElementById || document.all) {
menuobj.innerHTML = thecontent;
}
else if (document.layers) {
menuobj.document.write(thecontent);
menuobj.document.close();
}
}

最后下面的部分在 onclick 期间不工作,但此警报有效

function show(which) {
alert("test");
document.getElementById("describe").style.visibility = 'visible';
}

有什么建议吗??

编辑:这是我正在点击的 href

<a style="color: #FFFFFF; text-decoration: none;" href="ATrendAnalysis.aspx">Trend Analysis</a>

最佳答案

你必须使用ClientScriptManager

http://msdn.microsoft.com/en-us/library/3hc29e2a.aspx

例子:

void Page_Load(object sender, EventArgs e)
{
if(checkDisplayCount.Checked)
{
String scriptText = "";
scriptText += "function DisplayCharCount(){";
scriptText += " spanCounter.innerText = " +
" document.forms[0].TextBox1.value.length";
scriptText += "}";
ClientScriptManager.RegisterClientScriptBlock(this.GetType(),
"CounterScript", scriptText, true);
TextBox1.Attributes.Add("onkeyup", "DisplayCharCount()");
LiteralControl spanLiteral = new
LiteralControl("<span id=\"spanCounter\"></span>");
PlaceHolder1.Controls.Add(spanLiteral);
}
}

关于c# - 单击按钮后回发后如何显示 div?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9803254/

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