2012年11月8日 星期四

Q&A: EntityDataSource

 

  • VS2012+ Windows 8
  • ASP.NET 4.5
  • for Lab1.5

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

CTRL+F5

image

image

 

image

CTRL+F5

image

2012年11月7日 星期三

Q&A ASP.NET Dynamic Data 實體網站 -客製化

 

延續此文範例 Q&A ASP.NET Dynamic Data 實體網站

  • VS2012+ Windows 8
  • ASP.NET 4.5
  • for Lab2.3 自訂網頁範本

修改global.asax

image

加一個authors目錄

image

image

image

客製化,如加上字串

image

run

image

Q&A ASP.NET Dynamic Data 實體網站

 

  • VS2012+ Windows 8
  • ASP.NET 4.5
  • for Lab2.1 使用動態資料與語意標註

Visual Studio 2012 的ASP.NET Dynamic Data 實體網站範本,使用Entity Framework 5.0,因此要啟用Dynamic Data的語法有一點不同:

1.

image

Add ADO.NET Entity Data Model

image

image

image

image

image

image

 

修改global.asax,RegisterRoutes方法:

PS:這部分和VS2010最大不同的是DefaultModel.RegisterContext的寫法,需這樣寫

DefaultModel.RegisterContext(() =>
{
  return ((System.Data.Entity.Infrastructure.IObjectContextAdapter)new pubsEntities()).ObjectContext;
}, new ContextConfiguration() { ScaffoldAllTables = true });

ex:

image

執行網站測試

image

App_Code目錄,Add authors class:

[MetadataType(typeof(AuthorsMetadata))]
[DisplayName("作者")]
public partial class authors
{
  private class AuthorsMetadata
  {
    [DisplayName("姓氏")]
    public string au_lname { get; set; }
    [DisplayName("名字")]
    public string au_fname { get; set; }
  }
}

Run

image
image

2012年11月6日 星期二

第一個jQuery Mobile範例–使用ASP.NET MVC 4 行動裝置範本

以下說明如何使用Visual Studio 2012 ,ASP.NET MVC 4 行動裝置範本設計第一個jQuery Mobile範例

1.Create Web AP

image

2.

image

3.在Models 目錄下加一個Employee  Class:

image

4.Employee  Class:

namespace MvcApplication6.Models {
  public class Employee {
    public int ID { get; set; }
    public string Name { get; set; }
    public int Age { get; set; }
  }
}

5.在Controllers目錄下加一個EmployeeController:

image

6.在EmployeeController使用GET的Create action 建立Create View:

image

 

image

7.修改有標示HttpPost的Create action:

[HttpPost]
public ActionResult Create( Employee model ) {
  try {
    // TODO: Add insert logic here

    return View( "Result" , model );
  } catch {
    return View();
  }
}

8.在上述步驟程式上方,按右鍵,建立Result View

image

9.按F5執行,URL輸入Employee/Create:

10.執行畫面:

image

按Create效果

image

 

11.在模擬器上效果。

image

image

總網頁瀏覽量