Click here to Skip to main content
15,887,822 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I have tried the save button and its succesful. kindly suggest the code for clear button.

What I have tried:

C#
public ActionResult Index(FormCollection frm, CategoryMaster cm)
       {
           string btnName = frm["save"];
           bool flag = false;
           if (ModelState.IsValid)
           {
               if (btnName == "Add")
               {

                   cm.freeze = "N";
                   cm.adduser = "Admin";
                   cm.adddatetime = DateTime.Now;
                   flag = cdal.AddCategories(cm);
                   if (flag)
                   {
                       @ViewBag.HideClass = "alert alert-success";
                       @ViewBag.Message = "Record Saved Successfully";
                   }
                   else
                   {
                       @ViewBag.HideClass = "alert alert-danger";
                       @ViewBag.Message = "Error! Record Not Saved";
                   }
Posted
Updated 27-Jun-16 4:32am
Comments
John C Rayan 24-Jun-16 11:06am    
Clearing the form fields on the client side/ You can use form reset.

1 solution

You can do this by multiple ways
1. Adding input type reset
HTML
<input type="reset" value="clear" class="btn btn-sm btn-primary" id="btnClear" />


2. By adding action link as follows
@Html.ActionLink("Clear", "Create", "", new { @class = "btn btn-sm btn-primary" })


3. Or on client side using jQuery


Hope that helps
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900