I have used a *required field validator*, on click of add Button error message will be displayed but whatever code written on onclick event will be executed even if the field is empty. 

```
<div class="form-group posrel">
    <asp:Label ID="Label1" runat="server" AssociatedControlID="txtDept"><i class="fa fa-pencil"></i></asp:Label>
    <asp:TextBox runat="server" ID="txtDept" placeholder="Department Name" ValidationGroup="ss1"></asp:TextBox>
    <div class="text-right validators">
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
            ErrorMessage="Department Name" ControlToValidate="txtDept" ValidationGroup="ss1">
        </asp:RequiredFieldValidator>
    </div>
</div>

```

Below is the code snippet of add button - 

```
<div class="form-group pull-right">
    <asp:LinkButton runat="server" ID="lnkbtnaddept" CssClass="btn btn-primary"  ValidationGroup="ss1" OnClick="lnkbtnaddept_Click">
        <asp:Label runat="server" Text="Add" ID="lbladddept"></asp:Label>
        <i style="margin-left: 10px;" class="fa fa-send"></i>
    </asp:LinkButton>
</div>

```