In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "how to use the Razor feature in ASP.NET MVC 3". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor learn how to use the Razor feature in ASP.NET MVC 3.
Start
Catalogue
Specify in _ ViewStart.cshtml
StartPage.Layout preloads this page when the program starts.
@ {Layout = "~ / Views/Shared/_Layout.cshtml";}
Implement the frame page
_ Layout.cshtml
@ View.Title @ * template page * @ Main @ RenderBody () bottom footer @ RenderSection ("footer")
@ RenderBody () renders the body.
@ RenderSection ("footer"); presentation section: such as the copyright at the bottom.
In Index.cshtml
@ section footer {copyrght@@facingwaller}
Display variables in view and variables in display control
Display the defined on the page
Display controller
The definition in control:
Display in view
Some other common writing methods
In VIEW
The variable use view variable:@ @ variable=@variable on the page comes from the controller's use Controller variable:@View.variable loop nested HTML Loops and Nested HTML Sample @ foreach (var p in words) {@ p. } use if else @ if (IsTrue) {@ @ IsTrue is @ IsTrue} else {@ @ IsTrue is @ IsTrue} multiple lines of code @ {var number = 1; var num2 = 2;} statements made up of Multi-Token Statements variables and strings @ (number + "number is" + number) HTML Encoding @ * the following do not understand-please advise * @ @ if (true) {hi it's razor follow me! I'm facingwaller hi it's razor follow me! Ihumm facingwaller} else {} Declarative HTML Helpers declares that the help method @ helper WordInText (string text) {foreach (var p in text) {@ p}} calls @ WordInText ("ender")
Final effect
Exciting RAZOR
Try fresh RAZOR this page engine, feel very good.
Replacing damned keys with @ is obviously very difficult to hit.
2 single-line @ + variables are more concise.
3 provides a large number of static helper methods.
4 the auxiliary methods of Chart and grid make charts and tables easier to generate and more user-friendly than the previous contrib open source table production class library.
WebImage helps create images, as well as basic image manipulation methods.
At this point, I believe you have a deeper understanding of "how to use the Razor feature in ASP.NET MVC 3". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.