My visit to TechDays paid off really will since i got a free copy of Telerik "Just Code". And this is a really nice tool to add to Visual Studio. JustCode assists in code analysis, refactoring, code formatting, etc. And it does this in a really good way. It allows me to easily find and fix code problems is an elegant and fast way. If you want to try it, visit http://www.telerik.com/products/justcode.aspx . I think you'll like it.
Web developers who would like to use CSS3 intellisense in Visual Studio 2010 can download this for free as an add-on form this website. Make sure you close VS before running the installer. The file should be automatically installed to C:\Program Files\Microsoft Visual Studio 10.0\Common7\Packages\1033\schemas\CSS .
Open up VS again and open a CSS file. You should be able to pick CSS3 from the style sheet toolbar. If not you should run the following registry script (don't forget to close VS before running the script):
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\Packages\{A764E895-518D-11d2-9A89-00C04F79EFC3}\Schemas\Schema 5]
"File"="css30.xml"
"Friendly Name"="CSS 3.0"
Open VS again and everything should work.
Happy CSS-ing.
URL Routing is a very nice new feature in ASP.NET 4.0. And in Visual Studio everything works just great. But as soon as you start testing on IIS you get a "Error 404.0 - Not Found".
To solve this you need to make sure that:
- you have set the Application Pool to "asp.net 4.0 application pool". Routing will not work with "asp.net 4.0 classic application pool".
- you add the following code to your web.config:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="UrlRoutingModule"/>
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</modules>
<handlers>
<add
name="UrlRoutingHandler"
preCondition="integratedMode"
verb="*" path="UrlRouting.axd"
type="System.Web.HttpForbiddenHandler, System.Web,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"/>
</handlers>
</system.webServer>
Routing should work in IIS as well now. Hope it helps.
Up to ASP.NET 3.5 Request Validation is enabled by default. In order to to disable this for a page you needed to set the ValidationRequest property in the page directive to false.
This is no longer the default case in ASP.NET 4.0. If you want to use this behaviour you need to add the follwing setting in web.config
<httpRuntime requestValidationMode="2.0" />
Of course you need to check all input in the page for XSS or other malicious input if you set the pages request validation to false.
Microsoft has made a target Schema for HTML 5 development. This schema can be installed on VS 2008 en VS 2010. You can download it form this website. Then run the installer.
If VS 2010 is not installed in it’s default location (C:\Program Files\Microsoft Visual Studio 10.00), then after running the .msi, you will have to manually move the ‘html_5.xsd’ to the location where VS 2010 is installed on your machine, for the intellisense to work properly.
Ever got bored of typing the same code over and over again? For example, if you want to use the IDataRecord to process a DataReader you will run into this code a lot:
s.Id = objIDR.GetInt32(objIDR.GetOrdinal("Id"));
s.Name = objIDR.GetString(objIDR.GetOrdinal("Name"));
Over and over again you need to call the GetOrdinal function to get the index of a field in the IDataRecord. You can reduce your typingwork a lot by using Extension Methods. They will encapsulate the GetOrdinal function into a new version of GetString or GetInt32. An Example:
Build a new static class which will contain the Extension Methods.
Add the following code to Extend the GetInt32 method of the IDataRecord interface:
public static Int32 GetInt32(this IDataRecord record, string field)
{
return record.GetInt32(record.GetOrdinal(field));
}
Make sure the method is declared static. You pass through 2 parameters. First the IDataRecord. Don't forget the "this" keyword because this is essential for an extension method. The IDataRecord is passed through automatically. Secondly pass through the name of the field you want to get the data from. Internally the GetOrdinal is used to retrieve te value.
But from whithin your app you can now call the GetInt32 method of the IDataReader as follows:
v.Id = objIDR.GetInt32("Id");
Where objIDR is an IDataSource object. You no longer need to code he GetOrdinal method because the exended GetInt32 does this job on its own. You can extend other methods of the IDataSource as well as methods of other data types or classes.
While testing an AJAX enabled web app I sometimes stumbled upon this script error: 'this.get_element().style' is null or not an object. It was a hard nut to crack this one. This was the actual message (in dutch, sorry

):
Bericht: 'this.get_element()' is leeg of geen object
Regel: 691
Teken: 13
Code: 0
URI: http://testsvnrekenmodule.dataleaf.nl/ScriptResource.axd?d=2EqeFsM1TXvejAN7rs-qRjWO1PqeNkBXDT2NkIE87E8D7WDMydoFVixUr4VEkAe74Gfs2uvzsMdh6_Qzi0k_G_ieMgZeXVZBgQ38L4KW1iU1&t=ffffffffc23ef909
The situation:
- AJAX Enabled web app using slider extenders (and hovermenu extenders).
- In some circumstances a script error is generated. In most cases it is not.
The reason:
It turned out that the error happens at times when a new Postback is triggered while a previous one hasnt finished yet. That is quickly changing the sliderhandle's position in this scenario. The Postback where triggered because i had set the AutoPostBack property of the extended TextBox to "true".
The solution:
Set the AutoPostBack property of the Extended TextBox to "false" and the sun will shine again.
While building a new website I stumbled upon a problem with the ASP.NET Menu Control. In all browsers, except IE8 the control works just fine. But in IE8 the dynamic parts of the menu are generated as blanks.
Some investigation on the net learned me that this in normal behaviour build into IE8 by Microsoft. (????) There seems to be a problem with compatibility. luckily the solution is fairly simple. just make sure that your page(s) get rendered in IE7 compatibility mode. To do this add the following line of code to the xhtml head element:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" >
By default IE7 does not allow the prompt() method to be executed. But you can enable this again.
In IE go to the menubar, select "Extra", "Options". Take the tab page "Security". Click the customize button at the security zone part. Look for "Websites are allowed to use scripts to prompt for information" and enable it. (screenshot on Dutch Vista)

Clikc "Ok" twice. Close your browser and open it again. The pompt() function should now work.