What is the @Html.DisplayFor syntax for?

Html.DisplayFor() will render the DisplayTemplate that matches the property’s type. If it can’t find any, I suppose it invokes .ToString(). If you don’t know about display templates, they’re partial views that can be put in a DisplayTemplates folder inside the view folder associated to a controller. Example: If you create a view named String.cshtml inside … Read more

How to write a comment in a Razor view?

Note that in general, IDE’s like Visual Studio will markup a comment in the context of the current language, by selecting the text you wish to turn into a comment, and then using the Ctrl+K Ctrl+C shortcut, or if you are using Resharper / Intelli-J style shortcuts, then Ctrl+/. Server side Comments: Razor .cshtml Like so: .aspxFor those looking … Read more

What does HTML.Raw do?

Text output will generally be HTML encoded. Using Html.Raw allows you to output text containing html elements to the client, and have them still be rendered as such. Should be used with caution, as it exposes you to cross site scripting vulnerabilities.

Why not use Html.EditorForModel()

Ok I just discovered about the EditorForModel in MVC and I want to know when I should use this instead of an EditorFor on each of my property? And why does when I add a strongly typed view it does not use this and build an EditorFor on every property? I’m late on this… but thanks for the info!

Differences between Html.TextboxFor and Html.EditorFor in MVC and Razor

The advantages of EditorFor is that your code is not tied to an <input type=”text”. So if you decide to change something to the aspect of how your textboxes are rendered like wrapping them in a div you could simply write a custom editor template (~/Views/Shared/EditorTemplates/string.cshtml) and all your textboxes in your application will automatically benefit from this change whereas … Read more

Failed to load resource: the server responded with a status of 500 (Internal Server Error) in Bind function

The 500 code would normally indicate an error on the server, not anything with your code. Some thoughts Talk to the server developer for more info. You can’t get more info directly. Verify your arguments into the call (values). Look for anything you might think could cause a problem for the server process. The process … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)