Model in Layout breaks other pages

前端 未结 1 377
不思量自难忘°
不思量自难忘° 2021-01-28 16:36

I have a design flaw based on my lack of MVC4 experience.

The issue is that I have a model in my Layout...

@model BasicFinanceUI.Models.LoginModel


        
1条回答
  •  终归单人心
    2021-01-28 17:07

    First build the view like you have it but instead of using helpers just build the html fields. Make sure you put an id or a class on the fields that we can use as a selector

     etc
    

    then make sure you have jquery referenced on the page and put this on the bottom of your screen

    
    

    then on your controller you need to have a method set up to receive the ajax call

    [HttpPost]
    public ActionResult Login(string UserName, string Password){
        //Check the user name and password against the database
        //from here http://stackoverflow.com/questions/10608198/asp-net-mvc3-returning-success-jsonresult
        var result=new { Success="True", Message="Success"};
        return Json(result, JsonRequestBehavior.AllowGet);
    }
    

    0 讨论(0)
提交回复
热议问题