In the ASP. NET MVC framework, the data in the view is passed to the controller, which is implemented primarily by sending forms. In use, the following three methods are used mainly.1. Read form data by Request.Form 2, read form data by FormCollection 3, directly read form data objectHere's a summary of what I learned from these things.1. Read form data via Request.Form first define a person class as follow
A partial view, which is part of the overall view. A single view page is displayed above the overall page, using the steps below1. Creating View data is ViewModel Public class Footerviewmodel { publicstringgetset;} Public string Get Set ; } }2. Create a partial
2014-06-18 BaoxinjianI. Summary
Described above in oaf according to the MVC architecture, divided into three layers, namely Model-view-contorl, on the oaf View layer of the basic concepts and some small cases
Page-Overview of pages
Key Properties for page
Key properties of item
Reusable component-Reusable components
c
If we need dynamic Ajax from the server to get HTML code, stitching strings is a bad way, so we write the HTML code in the cshtml file, and then through the code into the model, dynamically get cshtml in the HTML code
Of course, we want to use the common method to get cshtml, we must rewrite the Razorviewengine view engine, configure the view search location
When looking for a
that is going to be shown directly is copied in, it may be necessary to introduce a namespace @using xxx)Step three: The main view method receivesViewbag.id = ID;Jump to viewreturn View ();In the empty area of the view page, which is the HTML code that was taken to display the data, put@{html.renderaction ("demo", "", new {id = viewbag.id});}Fourth step: In the
converted//2, "is a special character in HTML and will be automatically parsed into quotation marks String htmlsingleform = @" When the index method in the controller is called, the index view is returned, followed by the code in the index view:@if (viewbag.form1!= null) { @Html. Raw (ViewBag.form1.ToString ()) //parsed into Html code displayed on page}Use the raw HTML method to parse the characters in
Several forms of ASP. net mvc passing parameters from a view to a controller, asp. netmvc
1. Pass the Array
$ (Function () {var value = ["C #", "JAVA", "PHP"]; $ ("input [type = 'click']"). click (function () {$. ajax ({url: "/Home/List", type: "Get", data: {valuelist: value}, traditional: true, // you must set this attribute, otherwise, the success: function (data) {alert ("Success") ;}}) ;}); public Actio
In ASP. NET, MVC transmits data from the background controller to the foreground view. asp. netmvc
This article describes how MVC transfers data from the background controller to the foreground view in ASP. NET. Share it with you for your reference. The specific analysis is as follows:
Data Storage Model:Copy codeThe C
. viewpage
"
%>
It represents thisViewUsedModelForMvcinduction. Models. People"
Summary:
1. viewdata and tempdata the method is weak to transmit data, while the Model data transmission is strongly typed.
2. viewdata and tempdata are completely different data types. viewdata the data type is viewdatadictionary class instantiation object, the tempdata data type is tempdatadictionary class instantiation object.
3. tempdata actually sav
ASP. NET mvc3 began to use razor as its view engine, replacing the original ASP. NET web form engine. I recently studied the implementation of razor in mvc3, and found a starting point to allow us to customize the view parsing Engine Based on razor syntax. It can be used in projects, such as mail template customization. Currently, it is only a demo version and is still being improved. Codeplex: http://codeo
A piece of code in ASP. NET MVC View:No problem, browser browsing is normal, the view element is:But if you are using a mobile browser, the view element is this:There is a "tel" hyperlink, and if you use native Javascript to get the element, get the following (mobile browser):var id = document.getElementById ("span_id"). Innerhtml;id = ' This is not what we want,
In recent development projects, the use of ASP . NET MVC because there is no contact before, for its value of the way some unfamiliar, here to carry out a preliminary summary of the accumulation of learning! One: UseViewData use:In the use, we can clearly see the difference between the two ways, just access is worth the way some difference!Public ActionResult Index (){listColors. ADD ("Red");Colors. ADD ("green");Colors. ADD ("Blue");viewdata["listcol
not contain a negative number (~) Starts with a character. This method returns the unchanged contentPath.
1
8. @ RenderSection ()
You can selectively define several different "sections" and allow the view templates designed based on this layout to overwrite them with custom content. This allows you to overwrite nonconsecutive sections on the layout design page in the view to make the layout design mor
Several ways to load partial views in summary view in ASP. NET MVC 4.0@RenderPage ()However, it cannot use the Model and ViewData of the original view, and can only be passed by parameters.1 @RenderPage ("~/shared/component/dialog.cshtml"new" Hello world! ", content="Nani" })The partial view receives data through the
In the [design article], we describe the principle of creating from viewresult to view rendering through a general introduction to the view engine, in order to give readers a deep understanding of the view engine and its view presentation mechanism, We have customized a simple staticfileviewengine for rendering static
development tools, such as JBuilder and eclipse, do not support view-layer interfaces very well (except for applications that use NotePad to write interfaces ), this makes the design of many MVC frameworks impossible.
As a friendly MVC framework, while simplifying the development of server applications, the design of the vie
The following is a summary of view Resolver in Spring 3 MVC:
1 internalresourceviewresolver
This is the most commonly used method for splicing returned views, for example:
Class = "org. springframework. Web. servlet. MVC. Support. controllerclassnamehandlermapping"/>
Class = "org. springframework. Web. servlet. View
No more nonsense to say, directly to everyone paste code.
Model:
Namespace Mvcapplication1.models
{public
class team
{public
string Preletter {get; set;}
public string Name {get; set;}}}
Asynchronously loading partial views through jquery
In home/index.cshtml view:
@{
viewbag.title = "Index";
Layout = "~/views/shared/_layout.cshtml";
}
HomeController Controller:
Using System.Collections.Generic;
Using Syst
In ASP. net mvc, data is transmitted from the front-end page View to the Controller mode.
Method 1:
Data storage Model: This method does not use the data storage Model. It only supports simple string data transmission.
Data View displayed on reception desk:Controller for processing data in the background:Public class TransportDataController: Controller {// GET:/T
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service