1. Gossip ASP. net mvc 3 beta
Without knowing it, MVC3 has been updated several times... This is because I have been developing Silverlight and have not paid much attention to ASP. net mvc. I read some articles in the garden before I made a preview.
However, I always think that dependency injection has long been a set, and the global interceptor is the same .. It seems that the development efficiency has not been greatly improved... (For your own opinion, I am currently learning the DI of MVC3BEAT ).
Except RAZOR...
Okay. Start now!
2. Commencement
2.1 directory
In _ ViewStart. cshtml, specify
StartPage. Layout will pre-load the page when the program starts.
- @{
- Layout = "~/Views/Shared/_Layout.cshtml";
- }
2.2 Implementation Framework page
_ Layout. cshtml
- <! DOCTYPE html>
- <Html>
- <Head>
- <Title> @ View. Title </title>
- <Link href = "@ Url. Content ("~ /Content/Site.css ")" rel = "stylesheet" type = "text/css"/>
- </Head>
- <Body>
- @ * Template page *@
- <Div>
- <Fieldset>
- <Legend> Main </legend>
- @ RenderBody ()
- </Fieldset>
- <Fieldset>
- <Legend> bottom footer </legend>
- @ RenderSection ("footer ");
- </Fieldset>
- </Div>
- </Body>
- </Html>
@ RenderBody () indicates the subject.
@ RenderSection ("footer"); rendering part: Copyright at the bottom.
In Index. cshtml
- @section footer{
- copyrght@@facingwaller
- }
2.3 display the variables in the view and the variables in the control.
Display
Display Controller
Definition in control:
Display in view
2.4 others
VIEW
- <Fieldset>
- Use view variable: @ variable = @ variable
- <Br/>
- Use Controller variable: @ View. variable from the Controller
- <Br/>
- Nested HTML Loops and Nested HTML Sample
- @ Foreach (var p in words ){
- <Big> @ p... </big>
- }
- <Br/>
- Use if else
- @ If (IsTrue ){
- <B> @ IsTrue is @ IsTrue </B>
- } Else {
- <B> @ IsTrue is @ IsTrue </B>
- }
- <Br/>
- Multi-line code
- @{
- Var number = 1;
- Var num2 = 2;
- }
- Multi-Token Statements variable and string patchwork statement @ (number + "number is" + number );
- <Br/>
- HTML Encoding
- <Br/>
- @ * Do not understand the following-Hope you can advise *@
- @ If (true ){
- <Text>
- Hi it's razor <br/>
- Follow me! I'm facingwaller
- </Text>
- <Br/>
- <Span> hi it's razor <br/>
- Follow me! I'm facingwaller </span>
- } Else {
-
- }
- <Br/>
- Declarative HTML Helpers declaration help Method
- @ Helper WordInText (string text ){
- Foreach (var p in text ){
- <Li> @ p </li>
- }
- }
- Call @ WordInText ("ender ")
- </Fieldset>
Final Effect
3 exciting RAZOR
The RAZOR page engine is quite good.
1 replace the damn <%> with @. Obviously <, %,> is a very difficult key.
2. The @ + variable method for a single row is more concise.
3. provides a large number of static helper methods.
4. Its Chart and grid auxiliary methods make it easier to generate charts and tables to be more user-friendly than the previous contrib open source table Production Class Library.
WebImage helps you create images, including basic image operations. In the future, I will continue to experience and compare these ideas and share them with you...
4. Welcome to discuss other page engines.
There is something to say. At present, I have not seen the source code of RAZOR and have never experienced other (except webpages) page engines.
If this is not the case, please help us out. You are also welcome to talk about other page engines, especially ease of use, design ideas, development efficiency and performance.
Click here to download the relevant source code