如何在mvc4弹出窗口上的按钮点击中插入数据? [英] How to insert data on button click that is on popup in mvc4?

查看:50
本文介绍了如何在mvc4弹出窗口上的按钮点击中插入数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在点击登录按钮时创建了一个弹出窗口,并且还使用了部分视图

但是表单显示正常但是点击登录按钮后就是

popup它可以去控制器或任何地方,所以请看这个代码并告诉我如何解决这个感谢!!





CSHTML代码: -



I have created a popup on click of login button and have also used a partial view
but the form appears fine but after clicking on login button that is on
popup it dosent go to the controler or anywhere so pls see this code and tell me how to solve that thanks!!


CSHTML CODE:-

@model MVCApplication10.Models.LoginModel
<script src="~/Scripts/jquery-1.8.2.js"></script>
<script src="~/Scripts/jquery-ui-1.8.24.js"></script>
<link href="~/Content/themes/base/jquery.ui.core.css" rel="stylesheet" />
<link href="~/Content/themes/base/jquery.ui.dialog.css" rel="stylesheet" />
 @Styles.Render("~/Content/themes/base/css", "~/Content/css")
<script type="text/javascript">
    var $J = jQuery.noConflict();

    $J(function () {
        $J('#demo').dialog({
            autoOpen: false,
            width: 400,
            title: "Login",
            resizable:false

        });
        $J('#pop').click(function () {
            $J('#demo').dialog('open');
        });
    });
</script>
<style type="text/css">
  @Styles.Render("~/Content/themes/base/css", "~/Content/css")
</style>

@{
    ViewBag.Title = "Login";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Login</h2>

<input type="button" id="pop" value="New" />
@*<div id="demo" >*@
        @using (Html.BeginForm())
        {
            @Html.AntiForgeryToken()
   

            <fieldset>
                <legend></legend>

                <div class="editor-label">
                    @Html.LabelFor(model => model.Mobile)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.Mobile)
                    @Html.ValidationMessageFor(model => model.Mobile)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.Password)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.Password)
                    @Html.ValidationMessageFor(model => model.Password)
                </div>

                <p>
                    <input type="submit" value="Login" />
                    @Html.ValidationSummary(true)
                </p>
            </fieldset>
        }
@*</div>*@
<div>







模特课程: -








MODEL CLASS :-


[Required(ErrorMessage = "Enter Mobile Number")]
       [Display(Name = "Mobile")]
       public decimal Mobile { get; set; }

  [Required(ErrorMessage = "Enter Password")]
       [Display(Name = "Password")]
       [DataType(DataType.Password)]
       public string Password { get; set; }










public bool IsValid(decimal Mobile,string Password)
       {
           var query = (from c in db.CustomerMasters where c.Mobile == Mobile && c.Password == Password && c.IsDeleted == false select c).SingleOrDefault();
           if(query!=null)
           {
               return true;
           }
           else
           {
               return false;
           }
       }









< b>控制器类: -







Controller Class :-

[HttpGet]
        public ActionResult Login()
        {

            return View();
        }
        [HttpPost]
        public ActionResult Login(LoginModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.IsValid(model.Mobile, model.Password))
                {
                    //FormsAuthentication.SetAuthCookie(user.UserName, user.RememberMe);
                    return RedirectToAction("About", "Home");
                }
                else
                {
                    ModelState.AddModelError("", "Invalide Mobile Number Or Password...!!!");
                }
            }
            return View(model);
        }

推荐答案

J = jQuery.noConflict();
J = jQuery.noConflict();


J( function (){


J(' #demo')。dialog({
autoOpen: false
width: 400
title: 登录
可调整大小: false

});
J('#demo').dialog({ autoOpen: false, width: 400, title: "Login", resizable:false });


这篇关于如何在mvc4弹出窗口上的按钮点击中插入数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆