Yanor.net/
Wiki
Blog
GitHub
Sandbox
開始行:
* HTMLヘルパー ActionLink [#w9b33181]
** Html.ActionLink [#f51dc9c9]
@Html.ActionLink(
"詳細", // リンク・テキスト
"Details", // アクション名
"Books", // コントローラ名
new { id = Model.Isbn }, // ルート・パラメータ
new { @class = "menu" } // そのほかの属性
)}
http://msdn.microsoft.com/ja-jp/library/dd504972(v=vs.108...
** 匿名型で使えないキー名を指定するには [#a2d64d90]
*** タグの属性のハイフンはアンダーバーに変換する [#oa6b40...
<a data-val="foo">CLICK</a>
↓
@Html.ActionLink("Goto","Index","Home",null, new {data_v...
http://www.itorian.com/2013/02/ajaxactionlink-and-htmlact...
*** DictionaryもしくはRouteValueDictionaryを使う [#ad9149...
@Html.ActionLink("Edit", "edit", "markets",
new RouteValueDictionary { { "foo.bar.baz", "abc" }...
new Dictionary<string, object> { { "class", "ui-btn...
- http://stackoverflow.com/questions/4108943/actionlink-h...
- http://msdn.microsoft.com/en-us/library/system.web.rout...
** クエリストリングではなくURLでIDを渡す [#c658c6ef]
*** ViewでのActionLinkの使い方 [#d5fa77a0]
@Html.ActionLink("ユーザ詳細", "detail", "user", new { i...
↓これで作成されるAタグ
<a href="/user/detai/123">ユーザ詳細</a>
*** ControllerでのURLパラメータの受け取り方 [#xe8c0e82]
[HttpGet]
public ActionResult Detail(int user_id) { }
*** デフォルトのRouteConfig.cs [#c49c170f]
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index...
);
このような<a href="/user/detai/123">のIDの受け取り方は↑で...
** 動的なクエリパラメータを渡す [#xc5c4824]
@{
RouteValueDictionary tRVD = new RouteValueDictionary(...
foreach (string key in Request.QueryString.Keys )
{
tRVD[key]=Request.QueryString[key].ToString();
}
}
@Html.ActionLink("Export to Excel", // link text
"Export", // action name
"GridPage", // controller name
tRVD,
new Dictionary<string, object> { { "class", "export" } }...
http://stackoverflow.com/questions/6165700/add-query-stri...
** リファレンス [#b8aa730e]
: MSDN Rendering a Form Using HTML Helpers | http://msdn....
: w3schools.com ASP.NET Razor | http://www.w3schools.com/...
: w3schools.com ASP.NET MVC - HTML Helpers | http://www.w...
: ASP.NET MVC 3 開発入門 (16) - HTML ヘルパーを活用 | htt...
: ASP.NET MVC入門 第3回 モデル・バインドとアノテーション...
終了行:
* HTMLヘルパー ActionLink [#w9b33181]
** Html.ActionLink [#f51dc9c9]
@Html.ActionLink(
"詳細", // リンク・テキスト
"Details", // アクション名
"Books", // コントローラ名
new { id = Model.Isbn }, // ルート・パラメータ
new { @class = "menu" } // そのほかの属性
)}
http://msdn.microsoft.com/ja-jp/library/dd504972(v=vs.108...
** 匿名型で使えないキー名を指定するには [#a2d64d90]
*** タグの属性のハイフンはアンダーバーに変換する [#oa6b40...
<a data-val="foo">CLICK</a>
↓
@Html.ActionLink("Goto","Index","Home",null, new {data_v...
http://www.itorian.com/2013/02/ajaxactionlink-and-htmlact...
*** DictionaryもしくはRouteValueDictionaryを使う [#ad9149...
@Html.ActionLink("Edit", "edit", "markets",
new RouteValueDictionary { { "foo.bar.baz", "abc" }...
new Dictionary<string, object> { { "class", "ui-btn...
- http://stackoverflow.com/questions/4108943/actionlink-h...
- http://msdn.microsoft.com/en-us/library/system.web.rout...
** クエリストリングではなくURLでIDを渡す [#c658c6ef]
*** ViewでのActionLinkの使い方 [#d5fa77a0]
@Html.ActionLink("ユーザ詳細", "detail", "user", new { i...
↓これで作成されるAタグ
<a href="/user/detai/123">ユーザ詳細</a>
*** ControllerでのURLパラメータの受け取り方 [#xe8c0e82]
[HttpGet]
public ActionResult Detail(int user_id) { }
*** デフォルトのRouteConfig.cs [#c49c170f]
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index...
);
このような<a href="/user/detai/123">のIDの受け取り方は↑で...
** 動的なクエリパラメータを渡す [#xc5c4824]
@{
RouteValueDictionary tRVD = new RouteValueDictionary(...
foreach (string key in Request.QueryString.Keys )
{
tRVD[key]=Request.QueryString[key].ToString();
}
}
@Html.ActionLink("Export to Excel", // link text
"Export", // action name
"GridPage", // controller name
tRVD,
new Dictionary<string, object> { { "class", "export" } }...
http://stackoverflow.com/questions/6165700/add-query-stri...
** リファレンス [#b8aa730e]
: MSDN Rendering a Form Using HTML Helpers | http://msdn....
: w3schools.com ASP.NET Razor | http://www.w3schools.com/...
: w3schools.com ASP.NET MVC - HTML Helpers | http://www.w...
: ASP.NET MVC 3 開発入門 (16) - HTML ヘルパーを活用 | htt...
: ASP.NET MVC入門 第3回 モデル・バインドとアノテーション...
ページ名: