Validating a Textbox for Decimal Values

by Edward 19 May 2011 17:32

It is always a good idea to try and validate any user input, before the page is submitted or a request is made to the database. This will cut down on unnecessary "back and forth" trips to the database, and also save on performance or showing nasty error pages, if you are not handling exceptions correctly.

To validate any user input, you can use the RegularExpressionValidator control provided with the .Net framework. If you need to validate other forms of input, such as query strings, cookies, or HTML input, you can use the System.Text.RegularExpressions.Regex class.

Here is small code snippet which will accept any numeric/decimal digits (e.g. 100.05), but not any alpha-numeric (e.g. £100.05). You must also have at least one digit before and one after the decimal place. It validates for a positive or negative currency amount. If there is a decimal point, it requires 2 numeric characters after the decimal point to be valid.

<asp:TextBox ID="txtAmount" runat="server" />
<asp:Button ID="btnSaveDetails" runat="server" Text="Submit" OnClick="btnSaveDetails_Click" />


<asp:RegularExpressionValidator ID="rvDecimal" ControlToValidate="txtAmount" runat="server"
ErrorMessage="Please enter a valid amount." ValidationExpression="^(-)?\d+(\.\d\d)?$">
</asp:RegularExpressionValidator>

Tags: , , , ,

ASP.NET | Other | Technology

Visual Studio 2010 SP1 BETA Released

by Edward 10 January 2011 18:56

At the end of last year(December 2010), Microsoft released a service pack for Visual Studio 2010. The service pack is still in BETA mode, and therefore must be treated as any BETA software.... handle with care!

I was happy to hear there was a new service pack on it's way, which has some bug fixes and includes fixes for the text editor when coding javascript, css, and html. One bug I wanted to see fixed was the 'crash bug' where my editor seems to crash unexpectantly when working with older versions of the .net framework. Since the install I have not had any crashes, although I must state that I have not been working a lot over the December/January period!

Visual Studio 2010 logoOther key updates to look out for, is that VS2010 SP1 BETA allows the debugger to support IIS Express. The IntelliTrace now also supports Workflows and projects that use Web Parts. There's also support for unit testing targeting .Net 3.5,  and support for Visual C++, Visual Basic, SQL Server Compact 4.0 Design-Time, with enhancements for web deployment.

If you want to download SP1 BETA, you can find the download page here, but like I said - make sure you know the risks of installing BETA software!

Tags: , , ,

ASP.NET | Development Resources | Technology

Microsoft Offers Development Software at No Cost - for 3 years

by Edward 29 November 2010 21:44

Last year Scott Guthrie from Microsoft announced on his blog that Microsoft is launching a new program called 'Websitespark'. This program is designed for independent web developers and web development companies that build web applications and web sites on behalf of others.  It enables you to get software for FREE. What is the catch? A one-time $100 Program Offering Fee is due upon exit or upon the end of the 3 year term! I thought I would share this with you, to encourage you to register and download this software.

Once you have enrolled, you can access the following software.

  • For design, development, testing and demonstration of new websites – for a total of up to three users per Web design and development company:
    • Visual Studio Professional
    • Expression Studio (1 user) and Expression Web (up to 2 users)
    • Windows Web Server 2008 R2
    • SQL Server 2008 Web Edition
  • For production use – that is, to deploy and host new websites developed using Program software – using a total of up to four processors per Web design and development company, of the following (physical or virtual) dedicated servers:
    • Windows Web Server 2008 R2
    • SQL Server 2008 Web Edition
In addition to software, Microsoft WebsiteSpark offers Web development and design companies the opportunity to:
  • Get Business Opportunities: Get opportunities to expand your customer base and drive new business through showcasing your capabilities and connecting with partners, by featuring your talents in Microsoft marketing and business networking vehicles.
  • Get Support and Training - benefits include:
    • 2 professional support incidents
    • Online support through Managed newsgroups on MSDN is no longer available. Priority support is now provided in MSDN forums and other Microsoft online properties
    • Access to broad community support through connections with Network Partners, Hosting Partners and peers with complementary services and technologies

You can register for the program by visiting the Microsoft Websitespark portal.

Tags: , ,

Development Resources | Other | Technology

IE9 Beta to be released this September

by Edward 17 August 2010 21:22

Microsoft announced that they are going to unveil Internet Explorer 9 (IE9) "Beta" next month(September 2010), at an event in San Francisco titled Beauty of the Web. While the browser wars for top spot are now between Internet Explorer, Firefox, Chrome and Opera, the latest version of IE9 will have to catch-up quickly. Microsoft seems to have missed a golden opportunity to make up for the failures of IE6 and IE7. Even Safari is making IE seem like an old browser and that is not even a target Windows platform browser.

By bringing out IE9 Microsoft seems to take something from Firefox Chrome. Some of the key features are that there are improved standards supports, as it scored an impressive 95% on the Acid 3 CSS test. IE9 also have better JavaScript and graphics performance, compared to previous versions. IE9 also implements enough of the HTML5 specification to raise the hope that stuffing rich content into browser plug-ins might not always be necessary.

As Microsoft is stating on its IE blog "IE9 offers consistent, fully hardware-accelerated text, graphics, and media, both audio and video", let’s hope Microsoft is starting to catch up and will continue to give users what they want from a browser experience.

Tags: , ,

Other | Technology

Download Updated VS2010 and .NET 4 Training Kit

by Edward 12 January 2010 14:41

The updated VS2010 and .NET 4 Training Kit includes presentations, hands-on labs, and demos. Some of the features include:

  • C# 4.0
  • Visual Basic 10
  • F#
  • Parallel Extensions
  • Windows Communication Foundation
  • Windows Workflow
  • Windows Presentation Foundation
  • ASP.NET 4
  • Windows 7
  • Entity Framework
  • ADO.NET Data Services
  • Managed Extensibility Framework
  • Visual Studio Team System

You can download the training kit from the Microsoft website.

Come next month, Microsoft will offer testers yet another development milestone release of both Visual Studio 2010 and .NET Framework 4.

This version of the Training Kit works with Visual Studio 2010 Beta 2 and .NET Framework 4 Beta 2.

Tags: , , , ,

ASP.NET | Development Resources | Technology

What is ahead for .Net in 2010?

by Edward 29 November 2009 18:04

We are almost at the end of 2009, and this year there have been some interesting things happening in the world of .Net and Microsoft. There was the release of Silverlight 3, Internet Explorer 8, updates to the AJAX library and toolkit, and just over a month ago we got Windows 7.

I thought I would point out a few new .Net technologies to look out for next year.

  • Visual Studio 2010 and ASP.Net 4.0: Microsoft already released beta versions of Visual Studio 2010 that will be running the ASP.Net framework 4.0. They aim to release the newest edition of Visual Studio and ASP.Net 4.0 on 22 March 2010.
  • MVC Framework: The first version of this framework has been released in March 2009. Currently MVC 2.0 Beta is available for download. Microsoft has made several changes to this framework since the first release. You should find the latest version available for download in the first half of 2010.
  • JQuery: It has taken Microsoft a while to wake up, but it is nice to know that JQuery is being adopted by Visual Studio. JQuery is a Javascript library that has a lot of neat tools in it's bag.  It is very helpful for taking care of mundane tasks like "get that div" or "set that text box value."  It also has a great set of methods for dealing with AJAX.  
  • WCF, WF and WPF: ASP.Net is a maturing framework that will continue to move forward, with or without you. The best advice I have is to get on the wagon. Tools and accompanying frameworks are maturing in line, but behind, the .NET framework - your applications should be as well.  The earlier you start, the better. WCF, or known as Windows Communication Framework, is used to abstract the "plumbing" of your application. It can save you hours and hours of coding.
  • Silverlight 4.0: Microsoft Silverlight is a web application framework that provides functionalities similar to those in Adobe Flash, integrating multimedia, graphics, animations and interactivity into a single runtime environment. Silverlight 4.0 Beta has been released last month, so do not be surprised to see the latest version available before June 2010.

Tags: , , , , , , , ,

AJAX/JQuery | ASP.NET | Development Resources | Technology

List of Windows 7 Shortcuts

by Edward 29 October 2009 18:08

As Windows 7 starts rolling out, and more people are starting to use it, I thought I would add a few Windows shortcuts.

The full list of keyboard shortcuts includes:

  • Win+Home: Clear all but the active window.
  • Win+Space: All windows become transparent so you can see through to the desktop.
  • Win+Up arrow: Maximize the active window.
  • Shift+Win+Up arrow: Maximize the active window vertically.
  • Win+Down arrow: Minimize the window/Restore the window if it's maximized.
  • Win+Left/Right arrows: Dock the window to each side of the monitor.
  • Shift+Win+Left/Right arrows: Move the window to the monitor on the left or right.


A list of shortcut combinations to launch the applications in their respective position on the taskbar:

  • Win+number (1-9): Starts the application pinned to the taskbar in that position, or switches to that program.
  • Shift+Win+number (1-9): Starts a new instance of the application pinned to the taskbar in that position.
  • Ctrl+Win+number (1-9): Cycles through open windows for the application pinned to the taskbar in that position.
  • Alt+Win+number (1-9): Opens the Jump List for the application pinned to the taskbar.
  • Win+T: Focus and scroll through items on the taskbar.
  • Win+B: Focuses the System Tray icons


A list of more advanced shortcuts:

  • Ctrl+Shift+N: Creates a new folder in Windows Explorer.
  • Alt+Up: Goes up a folder level in Windows Explorer.
  • Alt+P: Toggles the preview pane in Windows Explorer.
  • Shift+Right-Click on a file: Adds Copy as Path, which copies the path of a file to the clipboard.
  • Shift+Right-Click on a file: Adds extra hidden items to the Send To menu.
  • Shift+Right-Click on a folder: Adds Command Prompt Here, which lets you easily open a command prompt in that folder.
  • Win+P: Adjust presentation settings for your display.
  • Win+(+/-): Zoom in/out.
  • Win+G: Cycle between the Windows Gadgets on your screen.

Tags: , ,

Development Resources | Other | Technology

Microsoft announces the WebsiteSpark Program

by Edward 24 September 2009 14:10

Visibility, support and software for professional Web Developers and Designers - at no upfront cost!

Scott Guthrie from Microsoft today announced the WebsiteSpark Program, a program that encourages independent web developers or web development companies that build web applications on behalf of others. This program enables you to use strategic and sometimes expensive software from Microsoft for FREE, thus at no cost, for up to three years.

Here is a list of software you can enrol for:

  1. 3 licenses of Visual Studio 2008 Professional Edition
  2. 1 license of Expression Studio 3 (which includes Expression Blend, Sketchflow, and Web)
  3. 2 licenses of Expression Web 3
  4. 4 processor licenses of Windows Web Server 2008 R2
  5. 4 processor licenses of SQL Server 2008 Web Edition
  6. DotNetPanel control panel (enabling easy remote/hosted management of your servers)

The only two requirements to join the program are:

  •    Your company(or yourself if self-employed) builds web sites and web application on behalf of others.
  •    Your company currently has less than 10 employees.

For more information on this program, visit Scott's blog entry, or the program website.

Tags: , ,

Development Resources | Technology

C# 4.0 - Response.RedirectPermanent

by Edward 21 September 2009 13:48

As discussed in an earlier post, ASP.NET 4.0 introduces some SEO improvements, to build SEO friendly sites, or make sites "more friendly" to search engines. A new feature available in the HttpResponse Object, is the "Response.RedirectPermanent" response.

If you were to use "Response.Redirect()" to direct from one page to another (Page 1 to Page 2), the search engine will keep the first page in their index. In case the original page (Page 1) no longer exists, and you want Page  to replace Page 1, you need to indicate it with a Response Code "301", and that is why Response.RedirectPermanent() method. This response sends out a 301 response message, which indicates that the Page has moved permanently. Response.RedirectPermanent() also has an overload with one parameter, incase you need to use it.

Here is a code example:

     public static void RedirectPermanent(this HttpResponse Response, string PathUrl) 
     { 
         Response.Clear(); 
         Response.Status = "301 Moved Permanently"; 
         Response.RedirectLocation = PathUrl; 
         Response.End();    
     } 

Tags: , , , ,

ASP.NET | Technology

Microsoft roll out free trial of SQL Azure Database

by Edward 21 August 2009 11:55

Microsoft has rolled out a free trial of its cloud-based relational database, SQL Azure Database.

SQL Azure Database, a key component of the platform, is to rival Amazon's SimpleDB. SimpleDB is a distributed database written in "Erlang" by Amazon.com. It is used as a web service in concert with Amazon Elastic Compute Cloud (EC2) and Amazon S3 and is part of Amazon Web Services. Unlike the Amazon service however, it is a relational database. As with all cloud platforms, the idea is to provide scalable, hosted services on a pay-per-use basis, running remotely in Microsoft's datacentres.

Also available as a CTP. is the SQL Server Driver for PHP 1.1, which provides new capabilities for building PHP applications and support for SQL Azure, enabling developers to build PHP applications, with relational database capabilities using SQL Server or SQL Azure Database. 

With SQL Azure organizations will benefit from a pay-as-you grow model with enterprise-class availability, data protection, scalability, and security.

The free trial of SQL Azure Database will last until November, when the service is fully rolled out.

There will be two editions of the SQL Azure Database:

  • Web Edition storing up to 1GB of data and costing $9.99 (£6) per month, and
  • Business Edition that stores up to 10GB at $99.99 per month.

 

Tags: ,

ASP.NET | Development Resources | Technology

About DasCode.Net

I'm a ASP.NET web developer and code enthusiast. Blogging about everything .Net related.

Code... that's .net

Month List