Previous Button Clicked ID

Hi, I'm trying to fetch the previous Clicked Button ID and hide it as follows :

    public string PrevBtnID = string.Empty;
    public string Prevclickedvalue = string.Empty;
    private void Button_01(object sender, EventArgs e)
    {          
        Button btn = (Button)sender;
        if(Prevclickedvalue==string.Empty)
        {   
           // Storing clicked value text
            Prevclickedvalue = btn.Text;

            //Here needs to store current clicked button ID. But we are getting as GUID value whereas in quick watch we are getting correct ID "btn1"
            PrevBtnID =Convert.ToString(btn.Id);

        }
        else
        {
            if(Prevclickedvalue==btn.Text)
            {
                btn.IsVisible = false;
                Button btnhide = (Button)this.FindByName(PrevBtnID);
                btn.IsVisible = false;
            }
            else
            {

            }
        }
    }

In the above code, "btn.Id" we are getting some GUID instead of clicked button ID.

Thank you.

Sign In or Register to comment.