2014년 2월 5일 수요일

[C#, ASP.NET MVC]ASP.NET MVC4 예제, HelloWorld,닷넷강좌교육,오라클자바커뮤니티, 오엔제이프로그래밍실무교육학원, C#, ASP.NET교육, .NET MVC,모델,뷰,컨트롤러

[C#, ASP.NET MVC]ASP.NET MVC4 예제, HelloWorld,닷넷강좌교육,오라클자바커뮤니티, 오엔제이프로그래밍실무교육학원, C#, ASP.NET교육, .NET MVC,모델,뷰,컨트롤러

[HomeController.cs]

namespace HelloMVC3.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/

        public ActionResult Index()
        {
            ViewBag.CurrentTime = DateTime.Now.Date;
            return View();
        }

    }
}

[NoticeBoardController.cs]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace HelloMVC3.Controllers
{
    public class NoticeBoardController : Controller
    {
        //
        // GET: /Board/
      

        public ActionResult Board()
        {   
            Models.Board bo = new Models.Board();
            IEnumerable<HelloMVC3.Models.Board> Boards = bo.GetData();   //GetData();
            return View(Boards);
        }   
    }
}



[Board.cs]
namespace HelloMVC3.Models
{
    public class Board
    {
        
        public int ItemId { get; set; }
        public string Title { get; set; }
        public string Contents { get; set; }
        public string Author { get; set; }
        public DateTime Date { get; set; }

        public IEnumerable<Board> GetData()
        {
            IEnumerable<Board> Boards = new[]
            {
                new Board{ItemId=1, Title="TEST1", Contents="TEST1", Author="Admin", Date=DateTime.Now.Date},
                new Board{ItemId=2, Title="TEST2", Contents="TEST2", Author="Admin", Date=DateTime.Now.Date},
                new Board{ItemId=3, Title="TEST3", Contents="TEST3", Author="Admin", Date=DateTime.Now.Date},
                new Board{ItemId=4, Title="TEST4", Contents="TEST4", Author="Admin", Date=DateTime.Now.Date},
                new Board{ItemId=5, Title="TEST5", Contents="TEST5", Author="Admin", Date=DateTime.Now.Date},
                new Board{ItemId=6, Title="TEST6", Contents="TEST6", Author="Admin", Date=DateTime.Now.Date},
                new Board{ItemId=7, Title="TEST7", Contents="TEST7", Author="Admin", Date=DateTime.Now.Date},
                new Board{ItemId=8, Title="TEST8", Contents="TEST8", Author="Admin", Date=DateTime.Now.Date},
                new Board{ItemId=9, Title="TEST9", Contents="TEST9", Author="Admin", Date=DateTime.Now.Date},
                new Board{ItemId=10, Title="TEST10", Contents="TEST10", Author="Admin", Date=DateTime.Now.Date},
                new Board{ItemId=11, Title="TEST11", Contents="TEST11", Author="Admin", Date=DateTime.Now.Date}
            };
            return Boards;
        }        
    }
}

[Index.cshtml]

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
</head>
<body>
    <div>
    @Html.ActionLink("공지 사항", "Board", "NoticeBoard")
    <br /> 
        <!--ViewBag의 CurrentTime 동적 개체를 불러온다.-->
    현재 시간 : @ViewBag.CurrentTime
    <br />
    Hello, MVC 3 !!

    </div>
</body>
</html>


[Board.cshtml]

@model  IEnumerable<HelloMVC3.Models.Board>

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Board</title>
</head>
<body>
    
    <div>
     
        <table cellpadding="0" cellspacing="0" style="width:100%">
            <colgroup>
                <col />
                <col />
                <col />
                <col />
            </colgroup>
            <thead>
                <tr>
                    <th>ID</th>
                    <th>Title</th>
                    <th>User</th>
                    <th>Date</th>
                </tr>
            </thead>
            <tbody>
            @foreach (var i in Model) 
            {
                <tr>
                    <td>@i.ItemId</td>
                    <td>@i.Title</td>
                    <td>@i.Author</td>
                    <td>@i.Date</td>
                </tr>
            }
            </tbody>
        </table>
    </div>
        
    </div>
</body>
</html>




C#4.0, ADO.NET, Network 프로그래밍 5일 35시간   02-24
C#,ASP.NET마스터 18일 54시간   02-18
C#,ASP.NET마스터 8일 56시간   02-09
닷넷실무자를위한WPF개발자과정 8일 56시간   02-22 

댓글 없음:

댓글 쓰기