gpt4 book ai didi

c# - RegisterStartupScript 是否会增加页面大小

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

我在页面中使用这段代码:

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Timer ID="timer" Interval="4000" runat="server" OnTick="timer_Tick" />

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="pnlAlarm" runat="server" CssClass="pnlAlarm" ClientIDMode="Static">
<div id="Alarm">
<asp:Label ID="lblContent" runat="server" Text="Updating" CssClass="AlarmLogo"></asp:Label>
ClientIDMode="Static" />
</div>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="timer" />
</Triggers>
</asp:UpdatePanel>

在后面的代码中我使用了这个简单的代码:

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["nima"] = 1;
}
}
protected void timer_Tick(object sender, EventArgs e)
{
int i = int.Parse(Session["nima"].ToString());
if (i==3)
{
lblContent.Text = i.ToString();
ScriptManager.RegisterStartupScript(this, GetType(), "AlarmMessage", "$('#pnlAlarm').slideToggle();", true);
Session["nima"] = 0;
}
else
{
i = i + 1;
Session["nima"] = i;
}
}

我想知道每次使用 RegisterStartupScript 时,$('#pnlAlarm').slideToggle(); 添加到我的页面并增加我的页面大小?

谢谢

最佳答案

根据定义,该方法将:

register a startup script block that is included every time that an asynchronous postback occurs.

是的,它会被包含在内,因此会增加您的页面大小。

msdn ScriptManager.RegisterStartupScript Method

关于c# - RegisterStartupScript 是否会增加页面大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10026862/

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