Лекция: ASP скрипты

Пример скрипта, который возвращает текущее время:

<html>

<body bgcolor=«0xaabbee»>

<h1><center>TITLE</center></h1>

<hr />

<p> NOW IS <%Responce.Write Date %></p>

</body>

</html>

Пример скрипта, который получает данные из модели и создаёт новый объект типа Album:

@model MvcApplication1.Models.Album

@{ ViewBag.Title = «Создать новый»; }

 

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type=«text/javascript»></script>

<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type=«text/javascript»></script>

 

@using (Html.BeginForm()) {

@Html.ValidationSummary(true)

<fieldset>

<legend>Альбом</legend>

<div class=«editor-label»>

@Html.LabelFor(model => model.GenreId, «Жанр»)

</div>

<div class=«editor-field»>

@Html.DropDownList(«GenreId», String.Empty)

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

</div>

<div class=«editor-label»>

@Html.LabelFor(model => model.ArtistId, «Исполнитель»)

</div>

<div class=«editor-field»>

@Html.DropDownList(«ArtistId», String.Empty)

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

</div>

<div class=«editor-label»>

@Html.LabelFor(model => model.Title, «Название»)

</div>

<div class=«editor-field»>

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

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

</div>

<div class=«editor-label»>

@Html.LabelFor(model => model.Price, «Цена»)

</div>

<div class=«editor-field»>

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

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

</div>

<div class=«editor-label»>

@Html.LabelFor(model => model.AlbumArtUrl, «Обложка»)

</div>

<div class=«editor-field»>

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

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

</div>

<div class=«editor-label»>

@Html.LabelFor(model => model.AlbumRarUrl,«Архив»)

</div>

<div class=«editor-field»>

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

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

</div>

<div class=«editor-label»>

@Html.LabelFor(model => model.Description, «Описание»)

</div>

<div class=«editor-field»>

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

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

</div>

<p>

<input type=«submit» value=«Create» />

</p>

</fieldset>

}

 

<div>

@Html.ActionLink(«Вернуться назад», «Index»)

</div>

 

Класс Album:

using System;

using System.Collections.Generic;

using System.ComponentModel.DataAnnotations;

using System.Linq;

using System.Web;

namespace MvcApplication1.Models {

public partial class Album {

 

public virtual int AlbumId { get; set; }

public virtual int GenreId { get; set; }

public virtual int ArtistId { get; set; }

public virtual string Title { get; set; }

public virtual decimal Price { get; set; }

public virtual string AlbumArtUrl { get; set; }

public virtual string AlbumRarUrl { get; set; }

public virtual string Description { get; set; }

}

}

 

еще рефераты
Еще работы по информатике