Sunday, August 5, 2012
RenderAction versus RenderPartial
a talk a gave Tuesday on AJAX with MVC
can't see master pages in MVC3 or MVC4 at IIS7.5?
Put your site's folder IN the wwwroot folder and not parallel to it.Otherwise you sabotage the tilde! (& kill master pages) ...It took me FOREVER to figure out that I was breaking the ~ and while I was struggling I found this cute image:
Saturday, August 4, 2012
using
This explains why it is better to use an using statement to automatically dispose (will happen at the end of the using statement) of an object inheirting from IDisposable instead of just calling the .Dispose() method. In a nutshell using will call Dispose even if an exception occurs before the end of the using block is reached. This is yet more magic from C# 4.0 in a Nutshell.
Friday, August 3, 2012
keep a form from posting with jQuery in the name of validations without putting something goofy and old school inline in the form tag
<script type="text/javascript" src="Scripts/jquery-1.5.1.js"></script>
<script type="text/javascript">
$("form").submit(function () {
var poc = $("#ctl00_LayoutWorkspace_POC").val();
var title = $("#ctl00_LayoutWorkspace_ProjectTitle").val();
if (poc == "") {
$("#poc_warning").attr('style', 'color:Red;');
} else {
$("#poc_warning").attr('style', 'color:Red;display:none;');
}
if (title == "") {
$("#title_warning").attr('style', 'color:Red;');
} else {
$("#title_warning").attr('style', 'color:Red;display:none;');
}
if (poc == "" || title == "") {
return false;
} else {
return true;
}
});
</script>
some elementary asp:dropdownlist manipulations
This will add an empty ListItem at the end of an asp:dropdownlist.
POC.DataBind();
POC.Items.Add(new ListItem("",""));
This will add an empty ListItem at the beginning of an asp:dropdownlist and make it the default selection.
POC.Items.Add(new ListItem("",""));
POC.Items.Insert(0, new ListItem("", ""));
POC.Items[0].Selected = true;