开发者

Javascript causing multiple iterations through a custom page base in c# asp.net

开发者 https://www.devze.com 2023-02-19 15:04 出处:网络
I have searched for an answer and am at the end of the rope.I have a custom page base, when the head section has a script tag with a javascript onload(), the page base gets reloaded again for each one

I have searched for an answer and am at the end of the rope. I have a custom page base, when the head section has a script tag with a javascript onload(), the page base gets reloaded again for each one. If there are 4, the page goes through the overrides in the base the first time, the findcontrols all load, i insert some dynamic controls, and everything is great, then it cycles through the base again 4 more times.

PartialCachingControl ucHeader = (PartialCachingControl)Page.LoadControl("App_Controls/BaseHeaderControl.ascx");
HtmlContainerC开发者_运维问答ontrol divHeader = (HtmlContainerControl)FindControl("divHeader");

if (divHeader != null && ucHeader != null)
{
    divHeader.Controls.Add(ucHeader);

    if (ucHeader.Controls.Count == 0)
    {
        divHeader.Visible = false;
    }
}

The first time everything is right, I can find the controls in the usercontrol, and it runs beautifully, the second time, usercontrol controls are 0. SO, its not causing a problem on the page, because it cycles through, then ignores it, and continues.

Without any javascript it works perfectly.

The main problem is, I'm trying to make divs with no content not visible, so when I set (pseudo) if usercontrol control equals 0 usercontrol visible equals false, it isnt false the first time, but the second and subsequent times it is false, so it always ends up being false.

help.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号