Igor Kitsula - Developer

A Programmer Reference

 
  1  2  3  

How to: Turn on MVC compiled views or Turning on views compilation

Turning on views compilation will tell the compiler to compile your views and you will catch any errors (in views code) whenever you compile. Very handy and saves sometime. Unfortunately, it does add some time to the build process. If you have a lot of views, this could be lengthy, so you may want to disable this later.

Read more...Read more...

Image + ActionLink = Html.ImageActionLink

If you want to put image inside link using HTML.ActionLink you can use next nice implementation of extension method:

Read more...Read more...

ASP.NET MVC Razor - output HTML string non escaped

How do you show (safe) HTML saved in DB in a Razor view? It always escapes stuff like <.

Supposing your content is inside a string named mystring...

In releases from Beta 2 and earlier you can do:

@(new HtmlString(mystring))

In releases after Beta 2 you will be able to do:

	@Html.Raw(mystring)

Source:

ASP .NET MVC 3: JQuery validation and Data Annotation or Unobtrusive Client Validation

In previous article I’ve show you how to validate form using jQuery validation plugin and view model Data Annotations. With MVC 3 Microsoft have implemented jQuery validation referring to standard Data Annotation attributes. Let me show you how to use it in simple example.

Read more...Read more...

MVC Handling and logging JavaScript errors

Most of browsers have window.onerror event which fired when JavaScript error occur. You can bind your function to this event which receives three parameters: message, URL and line number where error raised.

Let’s create function which will be graceful handling of JavaScript errors, send in poor JavaScript AJAX request all information about error and then we can log it with Log4Net and send email notice.

Read more...Read more...

MVC Custom Error Pages (Log to database with Log4Net and notify by email)

MVC Custom error pages (log to database with Log4Net and notify by email)
There is a lot articles in web how to create and use custom error pages. I tried to implement one more solution and give you my example how to handle and log errors on website using Log4Net library and notify about error by email.

Read more...Read more...

Using jQuery to submit ASP .NET MVC form

Simplest, easier and nice method to submit MVC form using jQuery AJAX:

$("formMapMarker").submit(function(e) {
	if ($("formMapMarker").valid()) {
		$.post($(this).attr("action"), $(this).serialize());
	}
	e.preventDefault();
});
Read more...Read more...

All about MVC validation with jQuery or Validate model with Data Annotations using jQuery

There are a lot of articles about validation in MVC. I’ve tried all of them and tried to find optimal and nice solution to validate model defined with Entity Framework, using Data Annotation attributes and have client-side validation related to these attributes using jQuery validation plugin. Too much? :) I don’t think so. Here is the solution.

Read more...Read more...

URL Rewriter. Remove default.aspx from the URL

Search engines (like Google) see URL which ends with trail slash "/" and URL with default document (default.aspx) at the end of the same URL as two different pages with the same content, title, etc. So for SEO purposes it’s good to get rid of default page at the end of URL. Here is simple rule for URL Rewriter to sole this problem.

Read more...Read more...

Configure Expired Headers on IIS7

YSlow: "Web pages are becoming increasingly complex with more scripts, style sheets, images, and Flash on them. A first-time visit to a page may require several HTTP requests to load all the components. By using Expires headers these components become cacheable, which avoids unnecessary HTTP requests on subsequent page views. Expires headers are most often associated with images, but they can and should be used on all page components including scripts, style sheets, and Flash." More…

Read more...Read more...
  1  2  3