In the intricate ballet of software development, anti-patterns represent the missteps — the common yet ineffective solutions to recurring design and programming problems. Unlike patterns, which are best practices that developers follow to create maintainable, scalable, and efficient software, anti-patterns are pitfalls that may seem to provide a quick fix but ultimately lead to additional […]
How to detect if the visitor of a website is running Windows Vista
Different languages have different ways of getting information about the visitors. However, most languages can get the User Agent, which provides us, the webmasters, with information about the visitor’s browser, plugins and operating system. For example if the user agent of a visitor is: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322) Windows […]
Object cannot be cast from DBNull to other types
This is a common error that you get when trying to display a field with no value (null), from a table. If for example you have a field where you store the age of the employee, but you don’t know the age of all employees, and thus those fields are set to NULL. Trying to retrieve […]
How to detect if the visitor of a website is using Internet Explorer 7 Beta 1
Looking at the user agent we get information about the visitors, such as the operating systems they are running, browsers they are using, or what version of .NET Framework they have installed. The user agent is retrieved differently depending on the programming language you are using for your website. Since Internet Explorer 6.0 is the dominant browser, […]
A page can have only one server-side Form tag
In ASP.NET 1.1, only one server-side form tag is allowed on a page. This error occurs if you have two or more server-side form tags on your page.A server-side form tag is the tag which has a runat=”server” attribute. If this attribute is missing, then it’s a typical HTML form tag. The conclusion is that you are […]
Using EnsureVisible() to scroll down to the bottom of a ListView
You can easily programatically scroll to the bottom of a ListView using the EnsureVisible() method. This method takes 1 parameter – the index of the ListViewItem that you want to ensure visibility for. The trick to keep the ListView scrolled down is to use the EnsureVisible() method every time a new item is added to the list, and pass that item’s index as a parameter. […]
ASP.NET DropDownList of countries
Below you can find a complete list of countries as ListItems inside an ASP.NET DropDownList:
Regex string for price validation
This is a very simple regex string that validates prices of the form x.xx, xx.xx, xxx.xx, x.xxx and so on (where x is a number between 0 and 9).
Items collection cannot be modified when the DataSource property is set
You have a control that supports data binding (such as a DropDownList or a DataGrid) which is binded to a DataSource (such as a database table, an XML file or an array). If you try to add new items to it after you binded to a DataSource, you will get the error Items collection cannot be […]
How to maximize the browser window using JavaScript
To maximize the browser window to fit the screen, we first move the window to the top left corner and then set its size to the size of the client’s desktop: