In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to use the auxiliary methods in MVC3, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.
one,
@ Html.TextBox ("txt", "hello", new {style = "width:1000px;height:1000px;"})
Generate tags:
two,
Special properties (class:c# reserved keywords)
@ Html.TextBox ("txt", "hello", new {style = "width:1000px;height:1000px;", @ class= "aa"})
Generate tags:
three,
Attributes with concatenated characters (for example: data_result)
@ Html.TextArea ("text", "hello", new {data_result = "data"})
Generate tags:
Hello
four,
@ using (Html.BeginForm ()) {}
Generate tags:
= add input element
-@ Html.TextBox
@ Html.TextBox ("Title", string.Empty) / / single-line input
Generate tags:
-@ Html.TextArea
@ Html.TextArea ("Title", string.Empty) / / Multi-line input
Generate tags:
-@ Html.Label
Html.Label ("Title", "Please enter:")
Generate tags:
Please enter:
-@ Html.DropDownList
Controller code:
Public ActionResult Create2 () {/ / radio collection, value field, text field, selected value ViewBag.Genre = new SelectList (db.Genres, "GenreId", "Name", 1); return View ();}
View code:
@ Html.DropDownList ("Genre", string.Empty)
-@ Html.ListBox (multiple choices are available)
@ {List listbox = new List (); listbox.Add ("a"); listbox.Add ("b"); listbox.Add ("c");} @ Html.ListBox ("listitem", new SelectList (listbox, "a"))
Controller code:
/ / public ActionResult Create2 () {/ / Radio collection, value field, text field, selected value ViewBag.Genre = new SelectList (db.Genres, "GenreId", "Name", 1); / / multiple selection ViewBag.Genre2 = new MultiSelectList (db.Genres, "GenreId", "Name", new List () {"1", "2"}); return View ();}
View code:
@ Html.ListBox ("Genre") @ Html.ListBox ("Genre2")
-@ Html.ValidationMessage ()
Controller code:
Public ActionResult Create3 () {return View ();} [HttpPost] public ActionResult Create3 (string text) {if (string.IsNullOrEmpty (text)) {ModelState.AddModelError ("text", "error"); return View () } else {return RedirectToAction ("Index");}}
View code:
@ {ViewBag.Title = "Create3";} Create3@using (Html.BeginForm ()) {@ Html.TextBox ("text") @ Html.ValidationMessage ("text")}
Thank you for reading this article carefully. I hope the article "how to use Auxiliary methods in MVC3" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you 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.