2

i have an HTML Button as:

 <asp:Button id="Button2" Text="Edit" class="but" runat="server"/>
<input id="Button2" type="button" value="Add" class="but" />

now, i want to set "display:none" to Add button when Click on Edit from code behind in

asp.net. without applying runat="server" to Add Button.

Help appreciated! Thanks

1
  • why use <asp:Button> if you don't want runat="Server"> Commented Mar 9, 2013 at 14:16

1 Answer 1

3

You will need to do several things in order to achieve this.

  1. Create a property in your code behind that has the style you wish:

    public string AddButtonStyle { get; set; }
    
  2. Use this in your markup for the button:

    <input id="Button2" type="button" value="Add" class="but" 
                                               style="<%:AddButtonStyle %>" />
    
  3. Set this style accordingly in the button click event:

    AddButtonStyle = "display: none;";
    

You may want to initialize the property to string.Empty on page init.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.