locked
Button Visibility RRS feed

  • Question

  • User-1499457942 posted

    Hi

      I have below code . i Want when form loads only Add button should be visible. 

    Secondly when user clicks on btnEdit Add button text should change to Update and Cancel button should also be visible.

       <asp:HiddenField ID="hdsaveType" Value="Add" runat="server" />
    <div class="form-group row">
    <label for="Code" class="col-sm-1 col-form-label">Code</label>
    <div class="col-sm-2">
    <asp:TextBox ID="txt_Code" CssClass="form-control" runat="server"></asp:TextBox>
    <%--<input type="text" class="form-control" id="txt_Code" placeholder="Code">--%>
    </div>
    </div>
    <div class="form-group row">
    <label for="Description" class="col-sm-1 col-form-label">Description</label>
    <div class="col-sm-4">
    <asp:TextBox ID="txt_Description" CssClass="form-control" runat="server"></asp:TextBox>
    <%--<input type="text" class="form-control" id="txt_Description" placeholder="Description">--%>
    </div>
    </div>
    <div class="btn-toolbar" role="toolbar" aria-label="Toolbar with button groups">
    <div class="btn-group" role="group">
    <asp:Button ID="btnSave" CssClass="btn btn-primary" runat="server" class="btn btn-primary" Text=" Add "></asp:Button>
    </div>
    <div class="btn-group" role="group">
    <asp:Button ID="btnCancel" CssClass="btn btn-primary" runat="server" class="btn btn-primary" Text=" Cancel "></asp:Button>
    </div>
    </div>

    Thanks

    Wednesday, August 22, 2018 10:27 AM

Answers

  • User465171450 posted

    The controls have a Visible property on them you can set to true or false. If you want a button to be hidden when they load the page, add visible="false" to the button markup.

    To change the text, in the buttons click handler just set the .Text property to something else, like btnSave.Text = " Update ";

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 22, 2018 11:32 AM