简体   繁体   中英

asp.net button not working or firing no postback

I have a asp.net button on my page Clicking on the button does not seem to get to the code I've tried setting the causes validation to false with no joy I've set a breakpoint on the code behind but it never gets there. This actually was working when I initally setup the button not sure why this has now stopped. I'm using an update panel further up the page as well but its outside the content of this button

when attempting a click it looks like postback doesnt even get initiated

                <asp:Button ID="btnRadioStatus" 
                    runat="server" 
                    OnClick="btnRadioStatus_Click" 
                    Text="Online Radio Status" 
                    Font-Size="Large" 
                    Width="40%" 
                    Height="300px" CausesValidation="false" 
                  />

Code behind is

 protected void btnRadioStatus_Click(object sender, EventArgs e)
        { 
            using (var client = new SshClient("172.16.0.54", "test", "test"))
            {
                client.Connect();
                client.Disconnect();

            }
        }

Nothing much in page load except for some checks

 protected void Page_Load(object sender, EventArgs e)
        {



            //check for daylight saving time
            dayLightSavingCheckAdjust();

            ReadMyData();



            System.IO.DirectoryInfo dir = null;
            // Dim files() As System.IO.FileInfo 'array of fileinfo objects


            //get the specified directory
            dir = new System.IO.DirectoryInfo("Images\\hadiths");


            string[] files = Directory.GetFiles(Server.MapPath("Images/hadiths/"));



            foreach (string str in files)
            {

                ClientScript.RegisterArrayDeclaration("imgfileName", "'" + Path.GetFileName(str) + "'");

            }
            checkRadioStatus();  //check is radio is online 

        }

the checkRadioStatus just checks for the mic and changes the text and backcolour

  public void checkRadioStatus()
        {

            using (var client = new SshClient("172.16.0.54", "test", "test"))
            {
                client.Connect();
                SshCommand strMicStatus = client.RunCommand(@"sudo amixer -c1 get Mic | grep Mono: | awk '{print $6}' | sed 's/\[//g;s/\]//g'");

                //  Console.WriteLine(strMicStatus);

                client.Disconnect();

                if (strMicStatus.Result == "on\n")
                {
                    btnRadioStatus.Text = "Radio is Online";
                    btnRadioStatus.BackColor = System.Drawing.Color.Red;
                }

                else
                {
                    btnRadioStatus.Text = "Radio is Offline";
                    btnRadioStatus.BackColor = System.Drawing.Color.Olive;
                }
            }


        }

解决了我的div的css的zindex为-1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM