Anjali Khan

Anjali Khan

  • 1.3k
  • 867
  • 189.6k

if i click on Register button form is not be submitted ?

Sep 7 2016 12:58 AM


Hi frnds

i created like wizard and m shareing my code..

but here if i click on Register button form is not be submitted ?

so anyone tell me what i did wrong?


model///

public class Customer
    {
        public string FirstName { get; set; }     
        public string LastName { get; set; }     
        public string Address { get; set; }
        public string City { get; set; }
        public string Phone { get; set; }
        public string Mobile { get; set; }
    }
    public class BasicDetails
    {
        [Required]
        [Display(Name = "First Name")]
        public string FirstName { get; set; }

        [Required]
        [Display(Name = "Last Name")]
        public string LastName { get; set; }
    }
    public class AddressDetails
    {
        [Display(Name = "Street Address")]
        public string Address { get; set; }

        [Required]
        [Display(Name = "City")]
        public string City { get; set; }
    }
    public class ContactDetails
    {
        [Display(Name = "Home Phone")]
        public string Phone { get; set; }

        [Display(Name = "Mobile Phone")]
        public string Mobile { get; set; }

    }

 


controller///

public class WizardFormController : Controller
    {
        // GET: WizardForm
        public ActionResult BasicDetails1()
        {
            return View();
        }
        [HttpPost]
        public ActionResult BasicDetails1(Customer model)
        {
            if (ModelState.IsValid)
            {
                ViewBag.Name = model.FirstName;
                ViewBag.Email = model.LastName;            
            }
            return View(model);
        }
        [HttpPost]
        public ActionResult BasicDetails1(BasicDetails data,
string prevBtn, string nextBtn)
        {
            if (nextBtn != null)
            {
                if (ModelState.IsValid)
                {
                }
            }
            return View();
        }
    }


view///

 <div style="height:20%;border:groove">
        <span id="spnEmp">INPUT SEETING</span>&nbsp;&nbsp;
        <span id="spnEmp">DESIGNING</span>&nbsp;&nbsp;
        <span id="spnEmp">PUBLISH</span>&nbsp;&nbsp;
    </div>

    <div id="label1" style="width:100%; height:100% ; border:groove">   
        <div id="div1">

            <h4>Basic Details</h4>

            @Html.LabelFor(m => m.FirstName)
            @Html.TextBoxFor(m => m.FirstName)
            @Html.ValidationMessageFor(m => m.FirstName)
            <br /><br />

            @Html.LabelFor(m => m.LastName)
            @Html.TextBoxFor(m => m.LastName)
            @Html.ValidationMessageFor(m => m.LastName)
            <br /><br />

        </div>

        <div id="div2">

            <h4>Address Details</h4>

            @Html.LabelFor(m => m.Address)
            @Html.TextBoxFor(m => m.Address)
            @Html.ValidationMessageFor(m => m.Address)
            <br /><br />
            @Html.LabelFor(m => m.City)
            @Html.TextBoxFor(m => m.City)
            @Html.ValidationMessageFor(m => m.City)

        </div>

        <div id="div3">

            <h4>Contact Details</h4>

            @Html.LabelFor(m => m.Phone)
            @Html.TextBoxFor(m => m.Phone)
            @Html.ValidationMessageFor(m => m.Phone)
            <br /><br />
            @Html.LabelFor(m => m.Mobile)
            @Html.TextBoxFor(m => m.Mobile)
            @Html.ValidationMessageFor(m => m.Mobile)


            @*<input type="button" value="submit" />*@
            <input id="btnAdd" type="SUBMIT" value="Register" />
        </div>

    </div>
<br /><br />
    <input type="button" id="prev" value="PREV" />
    <input type="button" id="next" value="NEXT" />

    <script type="text/javascript">
        $(document).ready(function () {

            // Hide all div

            $("#div2").hide();

            $("#div3").hide();

            $("#prev").hide();


            // Hide all div

            $("#spnEmp").click(function () {

                $("#div1").show();

                $("#div2").hide();

                $("#div3").hide();

                $("#next").show();

                $("#prev").hide();

            });


            $("#next").click(function () {

                if ($("#label1 div:visible").nextAll('div').length == 1)

                    $("#next").hide();

                if ($("#label1 div:visible").next().length != 0)

                    $("#label1 div:visible").next().show().prev().hide();

                else {

                    $("#label1 div:visible").hide();

                    $("#label1 div:first").show();

                }

                $("#prev").show();

                return false;

            });


            $("#prev").click(function () {

                if ($("#label1 div:visible").prev().length != 0)

                    $("#label1 div:visible").prev().show().next().hide(); else {

                    $("#label1 div:visible").hide();

                    $("#label1 div:last").show();

                }

                if ($("#label1 div:visible").nextAll('div').length > 0)

                    $("#next").show();

                if ($("#label1 div:visible").nextAll('div').length == 2)

                    $("#prev").hide();

                else

                    $("#prev").show();

                return false;

            });
        });
    </script>


Answers (3)