Posted by K. Scott Allen on Nov 30, 2009 in
Dotnet |
View Original Article
If you are an ASP.NET Web Forms programmer making the switch to ASP.NET MVC – what’s the first thing you should learn?
There are lots of candidates for the number one spot. Some people will say the first thing to do is learn and embrace the spirit of the MVC design pattern. Others might say you should learn how to unit test a controller, or learn how to use a view model.
My answer is:
Learn how to use an HTML <form>.
Please excuse the ASP.NET web forms programmer who forgets about the <form> tag. Although every .aspx file has one, they never need to touch it, or even look at it. The form tag is not only well hidden, but also constrained. It only take a few years to start thinking the web revolves around pages that only submit information back to themselves.
The most important things to lean (or relearn) are:
- You can use the method attribute of <form> to specify the HTTP method to use for submission (GET or POST).
- You can use the action attribute of the <form> to submit information to any URL.
- You can have multiple <form> tags on a single page.
Let’s look at each case.
Method Attribute – GET versus POST
There are two types of requests a web browser will use when communicating with a web server – POST requests and GET requests. Both are designed to do what they sound like – GET a response, or POST some information and receive a response. Web forms always use POST methods. HTTP POST is the best method to use when you are submitting information to a web server and changing state in your application. For example, if a user fills out a <form> with textbox and radio button controls full of patient information you want to save in a database, then POST is the HTTP method you should use. The browser will POST the user’s values to the server where you can save them in the database, and then you can respond and tell the user everything worked (or tell them something blew up).
On the other hand, an HTTP GET operation operation is the best way to submit information to a server when you are not changing state inside the application. The best example is a form used to search for information. You need to send search parameters to the server, but the search parameters aren’t creating new records in a database – they are only used as to query information.
<form action="/search" method="get">
<input type="text" name="searchTerm" />
<input type="submit" value="Search" />
</form>
If the user enters “baby blue bathysphere” into the textbox and clicks the button, the browser will send off a GET request with the following URL:
/search?searchTerm=baby+blue+bathysphere
Notice how the submitted form values are placed in the URL itself. Not only is a GET operation cacheable, but users can also bookmark the response to a GET submission because all the information needed to produce the page is in the URL. GET is the default value for the method attribute of a <form>, so if you don’t specify the method you’ll have a GET by default.
Actions
ASP.NET web forms always POST to themselves, which can be limiting. As the previous example demonstrates, you can set the action attribute to submit a form to any URL, even a URL pointing to another application on a different server. For example, the following HTML would send the user to Google (both Google and Bing both expect the search parameter to have the name “q”).
<form action="http://google.com/search" method="get">
<input type="text" name="q" />
<input type="submit" value="Search" />
</form>
You’ll usually be setting the action attribute to submit information to some controller action in your MVC application. The Html.BeginForm helpers will help build the correct <form> tag to reach the desired action for you. If we were using the first code-snippet in this post (the one with an action of “/search”), we could respond to the search request with the default action of a SearchController. The MVC framework can automatically pass the searchTerm form parameter as a parameter to the action.
public class SearchController : Controller
{
public ActionResult Index(string searchTerm)
{
// ....
return View();
}
}
Two Forms Are Better Than One
Well … not always.
There are times when having multiple <form> tags on a page is a good idea. You can have two distinct pieces of a page submit information to two different URLs. Multiple <form> tags regularly make sense on portal type pages that contain multiple sections with disparate functionality. Like an area that lets a user get a stock quote, and an area that lets a user search for a movie. These are two different tasks that will probably best be handled by two different controllers, two different URLs, two different forms, and two different sets of input controls.
<form action="/stock/quote">
<input type="text" name="symbol" />
<input type="submit" value="Quote It!" />
</form>
<!-- ... --->
<form action="/movie/search">
<input type="text" name="q" />
<input type="submit" value="Search" />
</form>
Not every scenario requires multiple forms, however. Sometimes you want a single form to provoke different behaviors from the server. For example, imagine a shopping page where a user selects some check boxes for products they are interested in. You might need a button allowing the user to submit this information to “compare products” and another button allowing the user to save the selected items in a “wish list”. Both buttons need to submit the same information to the server, so they’ll probably live inside the same form
<form action="products/shop" method="post">
<!-- -->
<input type="submit" name="task" value="Compare" />
<input type="submit" name="task" value="Save to wish list" />
</form>
Both buttons in the above form will force the browser to POST to products/shop. Notice how both buttons have the same value for the name attribute, but their values are different. In an MVC application you can create a controller to accept this form submission:
public class ProductsController : Controller
{
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Shop(string task)
{
// ...
return View();
}
}
The value of the task parameter in the Shop action will contain the value of the button – either “Compare” or “Save to wish list”. You can inspect this value and decide what to do next.
Conclusion
Having <form> tags available to due your bidding in an MVC application allows you a great deal of flexibility and control. Every bit you learn about using forms will give you an edge in building your application. Experiment with them, read about them, and learn to love them!
Posted by Silverlight Show on Nov 30, 2009 in
Virtualization |
View Original Article
In this article Mahesh Sabnis explains how user controls can be developed and how to display them at runtime.
A few days ago, I was discussing with one of my techie friends about Silverlight 3.0 user controls and loading these controls on demand for performing DB operations like insert, update and delete. During the discussion, he also insisted that these operations should be available based upon user authorization. I liked the idea and started working on it.
Tags: Application Packaging, Virtualization
Posted by Silverlight Show on Nov 30, 2009 in
Virtualization |
View Original Article
In this post David Anson discusses the new Silverlight/WPF Data Visualization Development release and updates his DataVisualizationDemos sample project.
As with previous Data Visualization Development Releases, I've updated to the most recent Toolkit code. And like last time, the Silverlight Toolkit shipped most recently so the code in the new Development Release is identical to what just went out with the Silverlight 3/4 Toolkits. However, people using Data Visualization on WPF 3.5 or 4 can take advantage of the latest changes by updating to the binaries included with this Development Release or by compiling the corresponding code themselves.
Tags: Application Packaging, Virtualization
Posted by Rich Tretola on Nov 30, 2009 in
Flex |
View Original Article
This week's poll was brought to us by Amy Blankenship. The Flex Framework supplies a component life-cycle that allows (or forces, depending on your perspective) Flex developers to defer the work necessary to respond to changing styles and properties until...
Tags: flashobjects, News & Events
Posted by Silverlight Show on Nov 30, 2009 in
Virtualization |
View Original Article
A new
training course on Silverlight 4 has been released on channel9.
The Silverlight 4 Training Course includes hands-on-labs, a video and a whitepaper designed to help you learn about the new features in Silverlight 4 focusing on three major areas: Enabling Business Application Development, Empowering Richer Experiences and Moving Beyond the Browser. Some of the new highly anticipated features include Printing, WebCam and Microphone support, custom right-click, rich text, HTML support and access to local files with trusted applications.
Tags: Application Packaging, Virtualization
Posted by vitaly on Nov 30, 2009 in
Design & Graphics |
View Original Article


By Robb Clarke
There are a lot of misconceptions when it comes to social media. People seem to think that every day standards and decency get tossed out the window because of the anonymity of the Internet. Unfortunately for those people, that’s not always the case. First off, the Internet is getting smaller, and by that, I mean that it’s getting easier to find out who people are. You know how the saying goes “It’s a small world.” That reigns true for the Internet, especially social media sites, as well. Everyone is connected one way or another. There’s a whole “Six Degrees of Separation” thing going on.
There are Ten Commandments of Social Media that you should always try to follow. They will not only make you a better person but they will make your followers that much more appreciative of what you have to say.
1. Thou Shalt Not Be a Narcissist
Social media is not all about you. It’s about people. It’s about being social, hence the name. Take the time to engage others in conversation. Don’t simply sign on and post something about yourself and leave.
For every one post that you make about yourself you should dedicate at least three to engaging others in conversation whether it’s Retweeting what they’ve said, commenting on their photo album or asking them how their day is. A little bit of human contact goes a long way in the social media world; after all, human contact is what the whole concept is based off of.
You need to immerse yourself in the community and become part of the conversation. Social media is about relationship building and if you’re just spouting out posts and Tweets about yourself then people will quickly lose interest in you and what you have to say.
2. Thou Shalt Listen to What Others Are Saying
This ties in with the previous commandment; social media is all about engaging others in conversation and to do that you need to first listen to what others have to say. Actively participating in conversation helps build relationships and listening is the most important part.
There are a lot of tools out there that will not only help you listen but will also help you engage. Tools like TweetDeck are fantastic tools for monitoring and engaging the conversations that are happening. TweetDeck is fantastic because you can not only monitor the obvious Twitter but you can also monitor Facebook and multiple other Twitter accounts.

TweetDeck Interface
3. Thou Shalt Not Spam
If you’ve been using email for the past 15-20 years then this shouldn’t come as a surprise. Don’t spam your friends and followers with links and chain letters other useless nonsense that just gets tossed in the trash or deleted.
Be courteous to others. Just because you think it’s cute to show 26 pictures taken milliseconds apart of your 9 month old rolling around on the floor doesn’t mean that anyone else will. Think about all of the things that make you roll your eyes when you read them on social media sites. Now think, do you do any of those things? If so, stop.
4. Thou Shalt Say Something of Substance
How often do you get online to find Joe blabbering on about his latest conquest at the bar or how many Filet o’Fish he’s eaten today? How many times have you seen Mary complain about how she didn’t get enough sleep last night or how her friends annoy her? Do these people really actually say anything? Usually not.
Far too often people take to social media sites to air their dirty laundry and complain about something and why? Would they be doing the same in front of a group of their friends, peers, coworkers, and prospective employers? Probably not. So why online?

Scott Stratten from UnMarketing made a great Tweet about posting on Twitter but the same applies for all social media sites. He said “Don’t tweet anything you wouldn’t want to see on a billboard with your name/face/logo/phone # and your mom driving by.” It’s true.
You wouldn’t be saying half of what you say online if it was real life so why do it? If anything what is said online is worse for your reputation than saying it in person. Why? Because it’s posted online and people can find it and reference it at any time.
The rule is simple; watch what you say and whom you say it to.
5. Thou Shalt Not Abuse Thy Neighbour
Tying in to the previous Commandment comes another Commandment that you would think would be pretty obvious but sadly it’s overlooked. Don’t abuse people online. Flaming on the Internet is just about as old as the Internet itself and it’s just as unacceptable as it has always been. No one wants to go online and be verbally assaulted for his or her beliefs and opinions. It’s not good form.
You know how the old saying goes; “If you can’t say something nice then don’t say anything at all.” Just because you’re online doesn’t make it acceptable to do. Chances are that you’re not going to openly mock or humiliate someone in person so why do it online?
6. Thou Shalt Give Credit Where Credit is Due
This is a Cardinal Sin in most circles, especially on Twitter. Stealing someone else’s ideas, quotes, pictures, whatever, are incredibly taboo not to mention amateur. You wouldn’t want someone coming along and stealing your intellectual property and posting it as his or her own now would you?
Here’s an example of the proper way to give someone credit for what they’ve said on Twitter.

How to Retweet Properly
Note that it’s perfectly acceptable to truncate words or paraphrase what was said if Retweeting takes up more than the allotted 140 characters.
7. Thou Shalt Learn How to Spell (or at least use a spell checker)
This one should be pretty obvious. Learn to spell and use grammar and punctuation properly. It’s incredibly hard to take what you’re saying seriously if it’s full of grammatical errors or you’ve mixed up your to, too and twos.
It’s not the hardest thing in the world to run your blog post through a word processor like Word before you post it. It’s actually in your best interest to type the whole thing in there in the first place regardless.
For those that are Tweeting or updating their Facebook statuses try using Mozilla’s Firefox. It has a built in spell checker. It won’t catch all of your spelling mistakes and it doesn’t catch grammatical or punctuation errors but it will put a dent into your typos.
8. Thou Shalt Use Real Words
The previous Commandment is the perfect segue into this next one. Please, for the love of all things holy, try your best to use real words. Seriously. Social media sites have turned people into absolutely horrible spellers and text and instant messaging aren’t doing people any favours either. Quit with the OMGs, the LOLs, the WTFs and the ROFLs.
Neil Patrick Harris had a brilliant Tweet making fun of people doing this. He said “Prfkt. Thx 4 L th advyc evry1. This s a way ezr way 2 cmuNik8. Un42n8ly, itz takn me 3 hrz 2 ryt, but itz much pre4d 2 gtn cut off lyk i u”. I don’t know what he said but that’s what he said. It shouldn’t take 140 seconds to try and decipher your 140 characters on Twitter. I know you’re doing it to “save time” but did you really save time? Did you actually cut seconds off of your posting time or did it really take you minutes longer to be “clever” and come up with those new words? Think about it.

Hard to read, isn’t it?
9. Thou Shalt Not Bear False Witness
Websites like TinyURL, Cli.gs and Bit.ly all offer a brilliant service; they take your exceptionally long URLs and turn them into short and sweet ones, perfect for the character limiting Twitter. These sites do have a downside though, they enable people to hide spam, porn or even the passé Rick Roll (yes, people are still doing that) in masked URLs.
When URLs are hidden like this users are unable to see where they’re headed and are often lead to undesirable websites. Be courteous to others and don’t hide links using these services.
That being said; these service providers do attempt to warn users of malicious websites that may be hidden in shortened URLs so there is light at the end of the tunnel.
On a related note; how many social media “experts” have you seen on Twitter that claim they know the key to being successful in both business as well as on social media sites? There are thousands of them out there. Do you know what their magic key is? The answer; our last Commandment.

Not Really Nick Nolte
10. Thou Shalt Not Be a Friend Whore
Last but certainly not least is our final Commandment of Social Media. Don’t be a friend whore. Social media is not a contest to see how many friends or followers you have. Having thousands of followers does not make you a better person or show that you’re a better quality user.
It’s incredibly common to see people on Facebook and Twitter adding as many people as they can as their friends in hopes that they befriend them in return simply to accumulate higher numbers.

Friend Whore Follows Three Users for Every One That Follows Them
Social media is not a contest. Plain and simple.
Following these Ten Commandments of Social Media will not only make you a better user of social media sites but they will also make your friends and followers appreciate you that much more. They aren’t hard to follow. Give them a shot.
Tags: How To's, Social Media
Posted by Silverlight Show on Nov 30, 2009 in
Virtualization |
View Original Article
Here is the first article of Gill Cleeren's
Silverlight Advent Calendar.
While browsing through the new properties and types available in Silverlight, I came across this nice little new property on the TextBlock called TextTrimming. As the word says, it helps you with showing an ellipsis when the text is too wide for the TextBlock you want it to appear in. Let’s take a look at this property in action.
Tags: Application Packaging, Virtualization