更新面板影响菜单元素

时间:2018-11-13 20:12:03

标签: asp.net webforms

我正在使用asp.net,webforms。 我有一个实时时钟,一些图像和菜单。为了更新时钟,我使用了UpdatePanel,它由计时器Tick事件触发。问题在于,即使它不是UpdatePanel的一部分,菜单也会受到影响。更确切地说,该子菜单不起作用,因此我无法访问任何根目录的子级。

                     
    <div class="container body-content">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="tmrClock" EventName="Tick" />
            </Triggers>
            <ContentTemplate>
                <asp:Image ID="imgPub1" runat="server" ImageUrl="~/Images/UPT.png" />
                <asp:Image ID="imgPub2" runat="server" ImageUrl="~/Images/UPT1.png" />
                <asp:Label ID="lblClock" runat="server" Text=""></asp:Label>
            </ContentTemplate>
        </asp:UpdatePanel>
        <div>
            <asp:Menu ID="Menu1" runat="server" BackColor="#F7F6F3" DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="Large" ForeColor="#7C6F57" Orientation="Horizontal" StaticSubMenuIndent="10px">
                <DynamicHoverStyle BackColor="#7C6F57" ForeColor="White" />
                <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                <DynamicMenuStyle BackColor="#F7F6F3" />
                <DynamicSelectedStyle BackColor="#5D7B9D" />
                <Items>
                    <asp:MenuItem NavigateUrl="~/About.aspx" Text="Acasa" Value="Acasa"></asp:MenuItem>
                    <asp:MenuItem Text="Manipulare Date" Value="Manipulare Date">
                        <asp:MenuItem NavigateUrl="~/Contact.aspx" Text="Actualizare Date" Value="Actualizare Date"></asp:MenuItem>
                        <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Adaugare Angajati" Value="Adaugare Angajati"></asp:MenuItem>
                        <asp:MenuItem Text="Stergere Angajati" Value="Stergere Angajati"></asp:MenuItem>
                    </asp:MenuItem>
                    <asp:MenuItem Selectable="False" Text="Tiparire" Value="Tiparire">
                        <asp:MenuItem Text="Stat de Plata" Value="Stat de Plata"></asp:MenuItem>
                        <asp:MenuItem Text="Fluturasi" Value="Fluturasi"></asp:MenuItem>
                    </asp:MenuItem>
                    <asp:MenuItem Text="Modificare Procente" Value="Modificare Procente"></asp:MenuItem>
                </Items>
                <StaticHoverStyle BackColor="#7C6F57" ForeColor="White" />
                <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                <StaticSelectedStyle BackColor="#5D7B9D" />
            </asp:Menu>
        </div>

这是OnTick代码:

protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        lblClock.Text = DateTime.Now.ToLongTimeString();
        imgPub1.ImageUrl = "~/Images/UPT.png";
        imgPub2.ImageUrl = "~/Images/UPT1.png";
    }
}

protected void tmrClock_OnTick(object sender, EventArgs e)
{
    Random rnd = new Random();
    int rndNum = rnd.Next(0, 2);
    if (rndNum == 0)
    {
        imgPub1.ImageUrl = "~/Images/UPT.png";
        imgPub2.ImageUrl = "~/Images/UPT1.png";
    }
    else
    {
        imgPub1.ImageUrl = "~/Images/UPT1.png";
        imgPub2.ImageUrl = "~/Images/UPT.png";
    }
    lblClock.Text = DateTime.Now.ToLongTimeString();
}

0 个答案:

没有答案