i have a web application,in which a user information form.i want to check if employee exist or not when user a user roll no which is also PK. THAT may be by using on text change or using button click eventasp:TextBox CssClass="form-control" runat="server" MaxLength="7" ID="txtRollNo" /> <asp:RegularExpressionValidator Display="Dynamic" ValidationGroup="vgEmployee" runat="server" ID="revRollNo" ControlToValidate="txtRollNo" Requried="required" ValidationExpression="^[A-Za-z0-9,/\,-]+$" ErrorMessage="Number,Alpha,- and / only" ></asp:RegularExpressionValidator> <asp:Button CssClass="btn btn-green btn-block " ID="btn_Click" Width="150" runat="server" OnClick="btn_Click_Click" CausesValidation="True" Text="Check Employee"/>
protected void btn_Click_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtRollNo.Text)) { Employee emp = _service.GetAllEmployee().Where(x => x.Employee_Id==Employee.Cnic).LastOrDefault(); if (emp != null) { MsgLitteral.ShowNotificationInline("Record Found", false); } else { MsgLitteral.ShowNotificationInline("Record Not Found", false); } } }