MVC 小笔记

一些关于Htmlhelper 和userhelper

Code
    <%= Html.Encode(this.ViewData["Injection"]) %>
    
<hr />
    
<%= Html.ActionLink("Go back to Index""Index"%><br />
    
<%= Html.ActionLink("Go back to Index with id = 1""Index"new { id = 1 }) %><br />
    
<%= Html.ActionLink<HomeController>(c => c.Index(), "Go back to Index"new { style="color:red;" })%>
    
<hr />
    
<%= Html.Select("select_sample"new int[]{12345}, 3%>
    
<hr />
    
<% using (Html.Form<HomeController>(c => c.Index(), FormMethod.Post))
       { 
%>
            
<%= Html.SubmitButton() %>
    
<% } %>
    
<hr />
    
<href="<%= Url.Action("Index") %>">Go back to Index</a><br />
    
<href="Index?data=<%= Url.Encode("Hello&World") %>">Hello World</a>



 
<%= Html.RenderUserControl("~/Controls/PartialView.ascx"%>

 

 

 

 

重定向、Redirect

 // Response.Redirect("/user/edit");
 // return Redirect("/user/edit");
 //  return RedirectToAction("index", "home");

URL Routing

 routes.MapRoute(
                "Default",                                                      // Route name
                "{controller}/{action}/{id}",                           // URL with parameters
                new { controller = "Home", action = "Index", id = "" }  // Parameter defaults

你可能感兴趣的:(MVC 小笔记)