<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>SuperSKa Weblog : ASP.NET MVC</title><link>http://msmvps.com/blogs/superska/archive/tags/ASP.NET+MVC/default.aspx</link><description>Tags: ASP.NET MVC</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>Using FCK Editor with ASP.NET MVC</title><link>http://msmvps.com/blogs/superska/archive/2009/04/06/using-fck-editor-with-asp-net-mvc.aspx</link><pubDate>Mon, 06 Apr 2009 11:22:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1685065</guid><dc:creator>Stefan Kamphuis</dc:creator><slash:comments>7</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/superska/rsscomments.aspx?PostID=1685065</wfw:commentRss><comments>http://msmvps.com/blogs/superska/archive/2009/04/06/using-fck-editor-with-asp-net-mvc.aspx#comments</comments><description>&lt;p&gt;First of, what is this &lt;a title="FCK Editor" href="http://www.fckeditor.net/" target="_blank"&gt;FCKEditor&lt;/a&gt;? Well, it&amp;#39;s an HTML Text Editor. It&amp;#39;s free and open source, cross browser, extensible and there are probably quite a few more buzzwords applicable. Oh... and it&amp;#39;s also the default HTML Text Editor provided with &lt;a title="DotNetNuke" href="http://www.dotnetnuke.com/" target="_blank"&gt;DotNetNuke&lt;/a&gt;. Fck Editor is soon to be replaced by &lt;a title="CK Editor" href="http://ckeditor.com" target="_blank"&gt;CK Editor&lt;/a&gt; but I&amp;#39;ll stick with Fck for now. CK will work mostly the same though.&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/superska/image_5F00_2.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/superska/image_5F00_thumb.png" align="right" border="0" width="244" height="213" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;First, you&amp;#39;ll need to &lt;a title="download Fck Editor" href="http://www.fckeditor.net/download" target="_blank"&gt;download Fck Editor&lt;/a&gt;. Unzip the downloaded file to see what&amp;#39;s in there.&lt;/p&gt;
&lt;p&gt;You&amp;#39;ll need to copy the &amp;quot;editor&amp;quot; folder over to you Contents folder in you ASP.NET MVC website. I chose the path &amp;quot;/Content/Js/ Fck&amp;quot; to paste it in.&lt;/p&gt;
&lt;p&gt;Two other files you might want to copy over to this same folder are in the root of the downoaded zipfile: &lt;i&gt;fckeditor.js&lt;/i&gt; and &lt;i&gt;fckconfig.js&lt;/i&gt;. The latter is expected by the editor and (suprisingly) contains configuration settings for the editor, while the first contains a few nice javascript functions to instanciate the editor.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/superska/image_5F00_4.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/superska/image_5F00_thumb_5F00_1.png" border="0" width="244" height="198" /&gt;&lt;/a&gt;&amp;nbsp; &lt;/p&gt;
&lt;p&gt;Next, include the fckeditor.js file in your page:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt; &lt;span class="attr"&gt;src&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;&amp;lt;%= Url.Content(&amp;quot;&lt;/span&gt;~/&lt;span class="attr"&gt;Content&lt;/span&gt;/&lt;span class="attr"&gt;Js&lt;/span&gt;/&lt;span class="attr"&gt;fck&lt;/span&gt;/&lt;span class="attr"&gt;fckeditor&lt;/span&gt;.&lt;span class="attr"&gt;js&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;quot;) %&amp;gt;&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;text/javascript&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;All set. Now you&amp;#39;ll need to add a textarea to your page:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="asp"&gt;&amp;lt;%&lt;/span&gt;= Html.TextArea(&lt;span class="str"&gt;&amp;quot;FckEditor1&amp;quot;&lt;/span&gt;, &amp;quot;Some Value&amp;quot;, &lt;br /&gt;  &lt;span class="kwrd"&gt;new&lt;/span&gt; { @name=&lt;span class="str"&gt;&amp;quot;FckEditor1&amp;quot;&lt;/span&gt; })&lt;span class="asp"&gt;%&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Important thing here, is the name property of the TextArea being set to the same value as the Id of it.&lt;/p&gt;
&lt;p&gt;To finish the client side of things off, you&amp;#39;l need to add some javascript to turn the textarea into a FckEditor at runtime. This can be copied from the samples of course, except for the Url.Contents part:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;window.onload = &lt;span class="kwrd"&gt;function&lt;/span&gt;()&lt;br /&gt;{&lt;br /&gt;  &lt;span class="kwrd"&gt;var&lt;/span&gt; sBasePath = &lt;span class="str"&gt;&amp;#39;&amp;lt;%= Url.Content(&amp;quot;~/Content/Js/Fck/&amp;quot;) %&amp;gt;&amp;#39;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;  &lt;span class="kwrd"&gt;var&lt;/span&gt; oFCKeditor = &lt;span class="kwrd"&gt;new&lt;/span&gt; FCKeditor( &lt;span class="str"&gt;&amp;#39;FckEditor1&amp;#39;&lt;/span&gt; ) ;&lt;br /&gt;  oFCKeditor.BasePath = sBasePath ;&lt;br /&gt;  oFCKeditor.ReplaceTextarea() ;&lt;br /&gt;}&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Now, to prevent the server error &amp;quot;&lt;b&gt;A potentially dangerous Request.Form value was detected from the client &lt;/b&gt;&amp;quot;, you should add the attribute &amp;quot;ValidateInput&amp;quot; to your controller&amp;#39;s action method like this&amp;quot;:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;[ValidateInput(&lt;span class="kwrd"&gt;false&lt;/span&gt;)]&lt;br /&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; ActionResult Save(&lt;span class="kwrd"&gt;int&lt;/span&gt; id)&lt;br /&gt;{&lt;br /&gt;    ...&lt;br /&gt;}&lt;/pre&gt;
&lt;p&gt;With this, you&amp;#39;re all set. The contents of the TextArea field you started out with, will contain the contents of the FckEditor control.&lt;/p&gt;
&lt;p&gt;Have fun! &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1685065" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/superska/archive/tags/ASP.NET+MVC/default.aspx">ASP.NET MVC</category><category domain="http://msmvps.com/blogs/superska/archive/tags/FckEditor/default.aspx">FckEditor</category></item><item><title>ASP.NET MVC: MultiSelectListBox without selection</title><link>http://msmvps.com/blogs/superska/archive/2009/03/16/asp-net-mvc-multiselectlistbox-without-selection.aspx</link><pubDate>Mon, 16 Mar 2009 07:31:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1678362</guid><dc:creator>Stefan Kamphuis</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/superska/rsscomments.aspx?PostID=1678362</wfw:commentRss><comments>http://msmvps.com/blogs/superska/archive/2009/03/16/asp-net-mvc-multiselectlistbox-without-selection.aspx#comments</comments><description>&lt;p&gt;Alright, now that was one hell of a mystery. For some odd reason my MultiSelectListBox didn&amp;#39;t show the selected items like it should.&lt;/p&gt;
&lt;p&gt;The case was very simple, and easily reproducible too. Start of in VS2008 with a new MVC Web Application, open up the HomeController class and change it&amp;#39;s code to this (only italic code was added):&lt;/p&gt;
&lt;pre class="csharpcode"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; HomeController : Controller&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; ActionResult Index()&lt;br /&gt;        {&lt;br /&gt;            ViewData[&lt;span class="str"&gt;&amp;quot;Message&amp;quot;&lt;/span&gt;] = &lt;span class="str"&gt;&amp;quot;Welcome to ASP.NET MVC!&amp;quot;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;            var dic = &lt;span class="kwrd"&gt;new&lt;/span&gt; Dictionary&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;, &lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;();&lt;br /&gt;            dic.Add(&lt;span class="str"&gt;&amp;quot;1&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;First thing&amp;quot;&lt;/span&gt;);&lt;br /&gt;            dic.Add(&lt;span class="str"&gt;&amp;quot;2&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;Second thing&amp;quot;&lt;/span&gt;);&lt;br /&gt;            dic.Add(&lt;span class="str"&gt;&amp;quot;3&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;Third thing&amp;quot;&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;            var sel = &lt;span class="kwrd"&gt;new&lt;/span&gt; ArrayList();&lt;br /&gt;            sel.Add(&lt;span class="str"&gt;&amp;quot;2&amp;quot;&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;            ViewData[&lt;span class="str"&gt;&amp;quot;multiselect&amp;quot;&lt;/span&gt;] = &lt;span class="kwrd"&gt;new&lt;/span&gt; MultiSelectList( dic, &lt;span class="str"&gt;&amp;quot;Key&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;Value&amp;quot;&lt;/span&gt;, sel);&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; View();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; ActionResult About()&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; View();&lt;br /&gt;        }&lt;br /&gt;    }&lt;/pre&gt;
&lt;p&gt;As you can see, this adds a MultiSelectList to the ViewData object. It conatins a dictionary with 3 items. In addition an ArrayList with 1 string is passed, to represent the selected items. Now, open up Home\Index.aspx and add the following code somewhere in the HTML-Body:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&amp;lt;%= Html.ListBox(&lt;span class="str"&gt;&amp;quot;multiselect&amp;quot;&lt;/span&gt;, ViewData[&lt;span class="str"&gt;&amp;quot;multiselect&amp;quot;&lt;/span&gt;] &lt;span class="kwrd"&gt;as&lt;/span&gt; MultiSelectList)%&amp;gt;&lt;/pre&gt;
&lt;p&gt;When running the application I expect the homepage to show up with the second item in the select list selected, but in stead it showsno selection at all:&lt;/p&gt;
&lt;p&gt;&lt;img style="border-right-width:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/superska/image_5F00_3.png" border="0" height="361" width="471" /&gt; &lt;/p&gt;
&lt;p&gt;It took quite some puzzling, but it the problem turned out to be caused by the element in ViewData having the same name as the Id for the control. If you change the line in Home\Index.aspx as follows:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&amp;lt;%= Html.ListBox(&lt;span class="str"&gt;&amp;quot;someMultiselect&amp;quot;&lt;/span&gt;, ViewData[&lt;span class="str"&gt;&amp;quot;multiselect&amp;quot;&lt;/span&gt;] &lt;span class="kwrd"&gt;as&lt;/span&gt; MultiSelectList)%&amp;gt;&lt;/pre&gt;
&lt;p&gt;The selection will finally show:&lt;/p&gt;
&lt;p&gt;&lt;img style="border-right-width:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/superska/image_5F00_6.png" border="0" height="359" width="466" /&gt; &lt;/p&gt;
&lt;p&gt;Pfff, glad I nailed that one...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1678362" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/superska/archive/tags/ASP.NET+MVC/default.aspx">ASP.NET MVC</category></item><item><title>ASP.NET: Leaping from Webforms to MVC - part 2</title><link>http://msmvps.com/blogs/superska/archive/2009/03/09/asp-net-leaping-from-webforms-to-mvc-part-2.aspx</link><pubDate>Mon, 09 Mar 2009 08:56:43 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1676866</guid><dc:creator>Stefan Kamphuis</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/superska/rsscomments.aspx?PostID=1676866</wfw:commentRss><comments>http://msmvps.com/blogs/superska/archive/2009/03/09/asp-net-leaping-from-webforms-to-mvc-part-2.aspx#comments</comments><description>&lt;p&gt;Alright, some time has passed since my &lt;a href="http://msmvps.com/blogs/superska/archive/2009/03/02/asp-net-leaping-from-webforms-to-mvc.aspx"&gt;previous post on this matter&lt;/a&gt;. And I must say, I&amp;#39;m not getting more enthusiastic on ASP.NET MVC. Not that it&amp;#39;s not good or anything, it just solves some problems I wasn&amp;#39;t experiencing (more on that &lt;a href="http://www.asp.net/learn/mvc/tutorial-01-cs.aspx"&gt;here&lt;/a&gt;). The main issue I&amp;#39;m running into is that my pages are somewhat dynamic. That means, based on several conditions, the form displays in one of several ways (for example: based on a property of an object a field displays as either a label or a textbox).&lt;/p&gt; &lt;p&gt;At this point I&amp;#39;m typing a whole lot of crappy code in my HTML within &amp;lt;% %&amp;gt; tags. It just feels soooo retro...&lt;/p&gt; &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/superska/image_5F00_2.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" border="0" alt="retro code" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/superska/image_5F00_thumb.png" width="644" height="199" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1676866" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/superska/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://msmvps.com/blogs/superska/archive/tags/ASP.NET+MVC/default.aspx">ASP.NET MVC</category></item><item><title>ASP.NET: Leaping from Webforms to MVC</title><link>http://msmvps.com/blogs/superska/archive/2009/03/02/asp-net-leaping-from-webforms-to-mvc.aspx</link><pubDate>Mon, 02 Mar 2009 15:06:57 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1675230</guid><dc:creator>Stefan Kamphuis</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/superska/rsscomments.aspx?PostID=1675230</wfw:commentRss><comments>http://msmvps.com/blogs/superska/archive/2009/03/02/asp-net-leaping-from-webforms-to-mvc.aspx#comments</comments><description>&lt;p&gt;Ever since late 2007 (I think &lt;img alt="Thinking" src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/72_72.gif" /&gt;) I&amp;#39;ve been reading quite a bit on the ASP.NET MVC framework. Even did some playing around here and there but never got to use it on a project. Until last week that is. I&amp;#39;m now working on a website that&amp;#39;s built entirely on the ASP.NET MVC framework. And of course, working on a project things are just a tad different from playing around a bit.&lt;/p&gt; &lt;p&gt;So, what is it that makes working with the MVC Framework so much different from Webforms? Well, let&amp;#39;s just put a small list here of some of the things I ran into. Needless to say that this is not a complete list, nor is it intended to be...&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Where are the servercontrols?&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Well, errrr, they&amp;#39;re gone. You don&amp;#39;t have them. You&amp;#39;re writing good old HTML again yourself. Of course, the advantage here is that you gain a lot of control over the HTML of your website. But, of course, no Servercontrols means &amp;quot;no events&amp;quot;. You even need to pull a trick to make a DropDownList autopostback (more on that &lt;a href="http://msmvps.com/blogs/superska/archive/2009/03/02/autopostback-dropdownlist-with-asp-net-mvc.aspx"&gt;here&lt;/a&gt;)...&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Only one &amp;lt;Form&amp;gt; in a page?&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Alright, an advantage of the MVC Framework. Every now and then I tend to run into this situation where I need some part of a page to submit to a different URL. In ASP.NET you need to use javascript &lt;img alt="Nerd" src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/49_49.gif" /&gt; to change the Action of the Form before it&amp;#39;s submitted. Or at least, that&amp;#39;s one approach of numerous you could choose from...&lt;/p&gt; &lt;p&gt;In ASP.NET MVC you can easily have different forms on a single page. Love that part&lt;img alt="Red Lips" src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/kiss.gif" /&gt;.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;More to come&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;... as I experience. I decided to post and update this one along the way.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1675230" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/superska/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://msmvps.com/blogs/superska/archive/tags/ASP.NET+MVC/default.aspx">ASP.NET MVC</category></item><item><title>Autopostback DropDownList with ASP.NET MVC</title><link>http://msmvps.com/blogs/superska/archive/2009/03/02/autopostback-dropdownlist-with-asp-net-mvc.aspx</link><pubDate>Mon, 02 Mar 2009 01:44:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1675241</guid><dc:creator>Stefan Kamphuis</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/superska/rsscomments.aspx?PostID=1675241</wfw:commentRss><comments>http://msmvps.com/blogs/superska/archive/2009/03/02/autopostback-dropdownlist-with-asp-net-mvc.aspx#comments</comments><description>&lt;p&gt;&lt;img style="border-right-width:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" alt="PropertiesPane" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/superska/image_5F00_3.png" align="right" border="0" height="219" width="318" /&gt;Didn&amp;#39;t you love the days back when you could just open up the properties tab for your DropDownList in ASP.NET and set the AutoPostBack Property to True? You could even write code in your codebehind class to handle the event properly. Cool, right? &lt;img alt="Hot" src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/shades_smile.gif" /&gt;&lt;/p&gt;
&lt;p&gt;But these are the days of the ASP.NET MVC framework, so everything&amp;#39;s different now. Well, of course I&amp;#39;m being a bit sarcastic &lt;img alt="Sarcastic" src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/50_50.gif" /&gt; here and there are a lot of advantages too to the MVC Framework, but still it requires more work to achieve things-that-used-to-be-simple.&lt;/p&gt;
&lt;p&gt;Anyway, back to the AutoPostBack of the DropDownList. First, of course, you need to have a DropDownList on your page:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;select&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;#39;dropDown&amp;#39;&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;#39;dropDown&amp;#39;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;option&lt;/span&gt; &lt;span class="attr"&gt;value&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;selected&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;selected&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Option 1&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;option&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;option&lt;/span&gt; &lt;span class="attr"&gt;value&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;2&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Option 2&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;option&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;select&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span class="kwrd"&gt;Note that this control needs to be within your Form otherwise it&amp;#39;s values will not be submitted of course...&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="kwrd"&gt;When you have the control, you&amp;#39;ll need to make it submit the Form it&amp;#39;s in. I chose to do so with jQuery, but you could &lt;a href="http://weblogs.asp.net/jdanforth/archive/2008/08/28/auto-postback-with-javascript-in-asp-net-mvc.aspx" target="_blank"&gt;do it with plain javascript&lt;/a&gt; too:&lt;/span&gt;&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;#39;text/javascript&amp;#39;&lt;/span&gt;\&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;pre class="csharpcode"&gt;  $(&lt;span class="str"&gt;&amp;#39;#dropDown&amp;#39;&lt;/span&gt;).change(&lt;span class="kwrd"&gt;function&lt;/span&gt; () {&lt;br /&gt;    $(&lt;span class="kwrd"&gt;this&lt;/span&gt;).parents(&lt;span class="str"&gt;&amp;#39;form&amp;#39;&lt;/span&gt;).submit();&lt;br /&gt;  });&lt;/pre&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;For those of you not fully up to speed with jQuery: this code finds the element named &amp;quot;dropDown&amp;quot; and adds a handler to the onChange event of it. The handler first finds the parent of the DropDownList with elementname &amp;quot;form&amp;quot;, and submits it.&lt;/p&gt;
&lt;p&gt;You could also change the action of the form here in the handler if that might be needed, for example to fire a specific controller action for the postback of the DropDownList.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1675241" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/superska/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://msmvps.com/blogs/superska/archive/tags/ASP.NET+MVC/default.aspx">ASP.NET MVC</category><category domain="http://msmvps.com/blogs/superska/archive/tags/jQuery/default.aspx">jQuery</category></item></channel></rss>