Friday, April 24, 2009

How we do MVC

Source

Like many of the frameworks coming out of Redmond, MVC is not an opinionated framework. Rather, it is a framework that enables you to form your own opinions (good or bad). It’s taken quite a long way, with a very stable result at the end. It’s certainly not perfect, and there are a few directions we’d like to go differently given the chance. In the next few posts, I’ll elaborate with real examples on the big examples here, otherwise, I’d love to have people poke holes in our approach

Thursday, April 23, 2009

You Should Learn MVC (with 3 reasons)

Source

1 – Testability. No – not talking about the TDD variety, just testing in general. If you’re “not a testing person” that’s OK – the rest of the computer science world has embraced the idea that “testing what we build is a pretty good idea”. You don’t really want your clients to catch that silly “InvalidCastException” do ya? There’s LOTS of reasons to want to test – again not TDD – just good old Unit Testing! It’s easy peasy with MVC and this alone should pull you in to at least check it out – along with why testing can save you time and money.

2 – Control over HTML. I’m sure you’ve heard this before – mangled ID’s, non-validating HTML, etc. Why is this important? Because you might want to use client-side programming for something! I won’t bang this gong for too long – but it’s a lot more than “making ViewSource look pretty” – you’re communicating with super-finicky creatures (browsers) that love to argue – being able to smith the markup experience makes you a more valuable developer!

3 – Extensibility. Literally every part of MVC Is pluggable – and in the last 3 apps I wrote (Storefront, Nerddinner, and SubSonic’s MVC Starter) I used my own ViewEngine to save some time and work. I’ve spun up my own ControllerFactory so I can use IoC (which is awesome fun!) Understanding this is the keys to the kingdom for any developer! Have you ever been freaked out because you needed to use Page_PreRender to get something to load into the ControlTree properly so it will show when you need it to? MVC does not lock you into anything – you’re free to do what you want to.

Wednesday, April 22, 2009

Basic Selectors in JQuery

1. By the ID attribute.
If the ID contains special character then you can escape them with backslashes. For example to find a text box with ID txtName you can write the following :

$("#txtName")

Then you can do any operation on the text box like getting the value or changing the css class.

2. By given element name. For example to get all the DIV elements following is the syntax

$("div")

This will find all the DIVs present in the page. You can do any operation after that.


3. By given class name. The following code finds all the elements which have class name 'RedButton'.

$(".RedButton")

Source

jQuery Auto-Complete Text Box with ASP.NET MVC

Great example:
Source

"HTTP Error 500 - Internal server error" mean: you have to fix something in your code

500 errors in the HTTP cycle

Any client (e.g. your Web browser or our CheckUpDown robot) goes through the following cycle when it communicates with your Web server:

Obtain an IP address from the IP name of your site (your site URL without the leading 'http://'). This lookup (conversion of IP name to IP address) is provided by domain name servers (DNSs).
Open an IP socket connection to that IP address.
Write an HTTP data stream through that socket.
Receive an HTTP data stream back from your Web server in response. This data stream contains status codes whose values are determined by the HTTP protocol. Parse this data stream for status codes and other useful information.
This error occurs in the final step above when the client receives an HTTP status code that it recognises as '500'.

Fixing 500 errors - general

This error can only be resolved by fixes to the Web server software. It is not a client-side problem. It is up to the operators of your Web server site to locate and analyse the logs which should give further information about the error.