谁有ASP.NET MVC3.0中自己写的登陆页面啊?急急急求

2025-02-26 19:45:01
推荐回答(2个)
回答1:

这里是Model

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

namespace MvcTest2.Models

{

    public class User

    {

        public string Name { get; set; }

        public string Password { get; set; }

    }

}


这里是控制器:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.Mvc;

using MvcTest2.Models;

namespace MvcTest2.Controllers

{

    public class HomeController : Controller

    {

        public ActionResult Index()

        {

            ViewBag.Message = "欢迎使用 ASP.NET MVC!";

            return View();

        }

        public ActionResult About()

        {

            return View();

        }

        //显示登录页面

        public ActionResult Login()

        {

            return View();

        }

        //这个是提交登录的

        [HttpPost]

        public ActionResult Login(User user)

        {

            //user中的Name属性和Password属性的值,就是你输入的用户名和密码

            return View();

        }

    }

}


这里是视图。这这里我用了默认的模板:

@model MvcTest2.Models.User

@{

    ViewBag.Title = "Login";

}

Login

@using (Html.BeginForm()) {

    @Html.ValidationSummary(true)

   

        User

       

            @Html.LabelFor(model => model.Name)

       

       

            @Html.EditorFor(model => model.Name)

            @Html.ValidationMessageFor(model => model.Name)

       

       

            @Html.LabelFor(model => model.Password)

       

       

            @Html.EditorFor(model => model.Password)

            @Html.ValidationMessageFor(model => model.Password)

       

       

           

       

   

}

这个视图是生成的,不是手敲的。不要告诉我你不知道这个视图是怎么生成的。


下面是效果图:

这里是后台的监视:


回答2:

这还用求啊,页面上放俩input,一个用户名一个密码,加个提交按钮不就行了,剩下的交给美工来搞

相关问答
最新问答