| 饼子天空 |
|
|||
| 个人程序Blogs | ||||
|
公告
日历
统计
导航 |
1 Html.BeginForm("Category", "Home",new { TestRoute1 = "test" },FormMethod.Post,new { id = "FormID" } ) 2 3 Html.BeginForm("Category", "Home",new RouteValueDictionary { {"TestRoute1", "test"} },FormMethod.Post,new Dictionary<string, object> { {"id", "FormID"} } )
4 <% using (Html.BeginForm("Category", "Home", new {TestRoute1=HttpContext.Current.Request.QueryString["TestRoute1"] }, FormMethod.Post, new {id = "FormID" })) { %>
相当于: <form action="Home/Category?TestRoute1=test" id="FormID" method="post"> <input type="submit" value="submit" name="subform" /> </form>
5 主要注意的是:object routeValues 与object htmlAttributes routeValues :就是你要传递的参数,eg:http://www.baidu.com/test.php?testid=abcdef 其中 testid=abcdef就是routevalues,或者再MVC中这样表示 new{testid="abcdef"}
htmlAttributes:就是对应的标签中的属性,在MVC中这样表示:new{@name="testName",@class="TestClass",@id="TestID"}
程序员问答社区,解决您的IT难题
|
![]() |
|
| Copyright © 饼子天空 | Powered by: 博客园 模板提供:沪江博客 |