2

hiding html buttons from code behind

<input id="Button1" type="button" value="delete" runat="server" class="bt1" onserverclick="button2" /> 

Code behind

Button mybut1 = (Button)FindControl("Button1"); mybut1.Visible = false; 

Another One

Button2.visible=false 

Both are not working

2
  • 1
    You cant access html buttons from code behind, Replace it with asp.net buttons Commented Feb 29, 2016 at 6:35
  • @Hemal we can access any html control from code behind, if it has ID and runat="server" attributes Commented Feb 29, 2016 at 6:40

1 Answer 1

4

Your html:

<input id="Button1" type="button" value="delete" runat="server" class="bt1" onserverclick="button2" /> 

You can use

Button1.Visible = false; 

Or

Button1.Style.Add("visibility", "hidden"); 

Both works.

Hope it helps you.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.