1. @Html the. Raw () method to output a string with an Html tag:
such as: @Html. Raw ("<div style= ' color:red ' >hello world!</div>")
Result: Hello world!
2. @html. ActionLink generates a <a href= "..." ></a> Tags:
such as: @Html. ActionLink ("LinkText", "ActionName", "ControlName", new {id = "911"},new{target= "_blank"})
Result: <a href = "/controlname/actionname/911" >linkText</a>
3. @Url. Action returns a URL
such as: @Url. Action ("ActionName", "ControlName", new {id = "911"})
Results:/controlname/actionname/911
4. @Html. Action loads the local page, the code for the public part, for example: Header/footer/menu/logout ...
such as: @Html. Action ("ActionName", "ControlName")
Usage similar to @html.renderaction
5. @Html. renderaction
such as: @{html.renderaction ("_vspartial", "Cmcontroller");}
_vspartial content:
@model activetesting<Div> <Div> <Div> <ul> <Li> <Div> <a>Hello world!</a> </Div> </Li>@if (Model! = null) {<Li><a>Li Li</a></Li> } </ul> </Div> </Div></Div>View Code
Principle: Executes according to the order of Controller→model→view, then returns the result
6. @Html. renderpartial
Embed the user control directly into the current page
such as: @{html.renderpartial ("_patientmrpartial");}
_patientmrpartial content:
<Div> <Div> <Div> <H3class= "Pull-left">Hello world!</H3> </Div> </Div> <Div> <Div> <Div> <Div> <Div>Tom</Div> </Div> </Div> </Div> <Divclass= "Row Cpnmedication-content-line"> <Div> <Div> <Divclass= "Pull-left">Jim</Div> </Div> </Div> </Div> </Div></Div>
View Code
C # ASP. NET MVC HtmlHelper Usage Summary