Actionlink
1. Add CSS to the link font. For example, add red
@ Html. actionlink ("<First page","Allmedias","Listenmedia",New{Page =1, Sortorder = viewbag. currentsort, currentfilter = viewbag. currentfilter },New{Style ="Color: red"})
2. If you append a parameter to the link, make sure that the following parameter is null. Otherwise, other methods will be reloaded, and the length of the ID will be passed in.
Html. actionlink ("Modify","Updatemediainfo","Listenmedia",New{Id = item. ID },Null)
If the Database Name of item. ID is ID. You can omit id =
Html. actionlink ("Modify","Updatemediainfo","Listenmedia",New{Item. ID },Null)
3. If it is opened in a new window (target = "_ blank ").
Html. actionlink (httputility. htmldecode (@ html. displayfor (x => item. Title). tostring ()), " Showmedia " , New {Item. ID, item. specialtitle }, New {Target = " _ Blank ", Style = "color: Red"
})
4. If you click a delete link, the delete or not dialog box is displayed,
@ Html. actionlink ("delete this media from database", "deletemedia", "listenmedia", new {@ model. ID}, new {id = "reportlink "})
$ ('# Reportlink'). Click (Function(){VaRX = confirm ("delete from database? ");If(X =True) {// Do something}Else{Return False;}});
5. If the link Image
<A href ="@ URL. Action ("Cutimg","Listenmedia", New {item, id = viewbag. ID })"> <IMG id ="@ Item"Src ="@ Item"Width ="200"Height ="100"/> </A>
6.Html. Raw
If you want to output <br> XXX <br> as HTML to the page.
@ Item. Name: Double quotation marks are displayed as strings.
Use @ html.raw(viewbag.html content)
HTML is displayed on the page as HTML.
7. Sometimes you want to display a default value for @ html. textboxfor or @ html. editorfor, such as automatically generating a guid Value
According to the principle, it should be okay to write in this way.
@ Html. textboxfor (C => C. propertyname, new {@ value = "5 "})
@ Html. editorfor (C => C. propertyname, new {@ value = "5 "})
But it does not work. Therefore, you must use HTML tags directly.
<InputValue= "@ Guid. newguid ()"ID= "UUID"Name= "UUID"Type= "Text"Value= "" />
OK. Another method is to set the default value, but it is not flexible.
Public class myvm {int _ propertyvalue = 5; // set the default value public int propertyname {get {return _ propertyvalue ;}set {_ propertyvalue = value ;}}}
Will be added at any time!