Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does RegisterStartupScript increase page size

I'm using this code in a page:

<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>

and in code behind I use this simple code:

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;
    }
}

I want to know every time that I use RegisterStartupScript , $('#pnlAlarm').slideToggle(); add to my page and increase my page size?

thanlks

like image 260
Arian Avatar asked Feb 16 '26 18:02

Arian


1 Answers

By definition, that method will:

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

So yes, it will be included, and therefore increase your page size.

msdn ScriptManager.RegisterStartupScript Method

like image 116
Rob Rodi Avatar answered Feb 18 '26 07:02

Rob Rodi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!