UpdatePanel不会设置Button属性 [英] UpdatePanel would not set Button properties

查看:82
本文介绍了UpdatePanel不会设置Button属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找在Timer Tick上更新BackColor按钮的可能性。每个Tick都有一个来自外部源的Dataimport。如果端口活动,则按钮应为绿色,否则应为红色。



按钮单击并单独在Windows应用程序中执行该过程。代码中有一个时间更新,它也有效。



On Timer Tick C#代码取自

I am looking for a possibility to update a button BackColor on Timer Tick. Every Tick there is an Dataimport from an external Source. If there is an Port "active" the Button should be GREEN, otherwise it should be RED.

The procedure work on Button click and separately in a Windows Application. There is an Time Update in the Code and it works, too.

On Timer Tick the C# Code takes the result from

res = dc.readBytes

并计算separeted Bits。如果位位置6的结果为1,则应为绿色,外部为红色。





这是ASP代码



and calculates the separeted Bits. If the result on Bit Position 6 is 1 it should be GREEN, outherwise RED.


Here is the ASP Code:

<asp:Content ID="Content2" ContentPlaceHolderID="ContentSection" runat="server">
    <form id="form2" runat="server">
      <asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeout="45">
      </asp:ScriptManager>
        <asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick" Interval="2000">
            </asp:Timer> 
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" RenderMode="Inline" UpdateMode="Conditional">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
            </Triggers>
              <ContentTemplate>
                  <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                  <asp:Label ID="Label2" runat="server">State</asp:Label>
                  <asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
              </ContentTemplate>
        </asp:UpdatePanel> 
            
        <asp:Panel ID="Panel1" runat="server">
            <asp:Button ID="ButtonLBuero" runat="server" Height="120px" OnClick="ButtonLBuero_Click" Text="Licht Büro" Width="120px" />
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
            
        </asp:Panel>
            
            
    </form>
</asp:Content>







这里是C#代码:






Here the C# Code:

protected void Timer1_Tick(object sender, EventArgs e)
        {
            Label1.Text = DateTime.Now.ToLongTimeString();
            Label3.Text = Convert.ToString(Connection);
            //Label4.Text = 
            if (Connection)
            {
                res = dc.readBytes(libnodave.daveOutputs, 0, 0, 1, null);



                if (res == 0)
                {
                    //int output = dc.getU8();
                    byte outputByte = Convert.ToByte(dc.getU8());
                    //label5.Text = Convert.ToString(output);



                    if (IsBitSet(outputByte, 6))
                    {
                        Label2.BackColor = Color.Lime;
                    }
                    else
                    {
                        Label2.BackColor = Color.Red;
                    }




                }

            }


        }





我认为UpdatePanel设置中有一个错误导致skripts自己运行。



I think there is an error in the UpdatePanel Settings cause the skripts running on ist own.

推荐答案

由于你的按钮不在更新面板中,所以它不起作用。所以我认为把你的按钮放在更新面板中然后就可以了。
As your button is not in the update panel so it won't work.So i think put your button in the update panel then it would work.


这篇关于UpdatePanel不会设置Button属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆