.NET
Using the RegularExpressionValidator for validating length of text
The RegularExpressionValidator can be used for almost everything regarding validation of input fields. My favourites are validating Email, Dates and length of text in textareas. The only problem with the length validation, is validating text that includes newline. One would think that the regex: .{0,4000} would be an easy way to validate maximum length of 4000 characters. That is true, but the dot does not include NewLine (CheatSheet). The RegularExpressionValidator also does NOT have an option for parsing the text as single line, which is a common Regular Expression option.
Reading another blog I found an expression that includes newlines: ^(.|\s){0,n)$
The only problem with this is that IE 6/7 and FF freezes when trying to test the expression. Seems like this is a JavaScript/ECMAScript problem. Disabling the clientscript for the RegularExpressionValidator however would probably solve this. The expression works fine in RegexCoach.
A comment in the blog suggested in using: ^[\s\S]{0,n}$
This expression seems to work fine in the browser. Also seems to work fine with number of characters. So I think I will stick with that for now.
Silverlight 2.0 Beta is here!
Finally, the first beta version of Silverlight 2.0 is here! You can download it at :
This download includes the plugin, the SDK and the Visual Studio 2008 tools.
Rumours say that the final release will be in September, but we will just wait and see…
You would also want to download Microsoft Expression Blend 2.5 Preview which has support for Silverlight 2
Just waiting for Scott Guthrie to start blogging about the details
SilverligthCalendar [updated]
The SilverlightCalendar is a Silverlight (obviously) application that I wrote back in 2007. I was originally written for Silverlight 1.0, but I have now upgraded it for Silverlight 1.1. The main features are the same:
- All the calendar data is fetched from an SQL server, using vanilla ADO.NET and webservices.
- All layout and controls are dynamically added to the root canvas. No hardcoded layout at all.
- Heavy use of animations, using storyboards.
- Everything is event based.
- Supports zindex for focusing objects
Additionally, the 1.1 version has the following new features:
- Much better use of custom controls and XAML. Use Expression Blend 2 (preview) to update XAML.
- Fullscreen support
- Resize support
- Additional fonts support
The interesting part in my opinion, is the integration with the business layer. This is usefull in real world scenarios, fetching data from data repositories or services and using the data in the Silverlight application.
SilverlightCalendar 1.0
The Silverlight application is written 100% in JavaScript. It is basiclly production ready, but it's hard to maintenance. The XAML is escaped in JavaScript which makes it incompatible with Expression Blend for instance. It is possible to extract the XAML and use a downloader object to make it less integrated in the JavaScript, so you are welcome to modify it if you like
Tools:
-
Visual Studio 2005
-
ASP.NET AJAX
Download the source code. Includes the database as well (SQLEXPRESS).
SilverlightCalendar 1.1
The 1.1 version is written in C# and is much more flexible and much easier to maintain. This is how real Silverlight applications should be written. Each Silverlight control is a custom control and can be modified in Expression Blend 2. That makes it really much easier to create the XAML and handle state in the control. In addition, a new set of tools were used to create it, making it easier to use and maintain.
Tools:
-
Visual Studio 2008
-
Silverlight 1.1 Alpha refresh SDK september
-
ASP.NET futures July 2007 (includes the XAML server control)
-
Silvelight 1.1 Tools for Visual Studio 2008 (makes the business interaction much more convenient using the "Add Silverlight link…" feature)
Additional tools:
-
Microsoft Expression Blend 2 Preview
Download source for SilverlightCalendar1.1 (including DB).
SilverlightCalendar2 [updated]
I have rewritten the calendar to support Silverlight 2 Beta 2
This version can be downloaded here.
Happy Silverlight coding
Me – the independent consultant
I recently quit my job in BEKK, and started as an independent consultant. If you need my services, especially in .NET and architecture, feel free to contact me.
Compressing ASPX, CSS and JS in ASP.NET 2.0
You always need to take some choices regarding performance on sites with a lot of traffic, and compression can be a solution. Of course, you need to be aware of the consequences by compressing. The CPU on the server and client will do some more work compressing and decompressing, but bandwidth will be significantly better.
By using the standard compression techniques like GZip and Deflate most modern browsers support compressed files. This was suggested in HTTP 1.0 and specified in HTTP 1.1. This also means that most crawlers and other services using standard protocols support compressed content.
So, what do you need ?
There are several ways to compress content and files. One is to let IIS compress it for you. I haven't tried this as people are reporting some hacking in the metabase in IIS to achieve this. Seems NOT the way to go, if you know what the metabase is.
The other approach is to write your own HttpModule and let this do the job. There are of course commercial products doing it for you, but it's not really a lot of code to create this module. You can start downloading Ivan Porto Carrero's excellent example. Compile it and add the http module to your web.config file. You should now see that the ASPX page is reduced to a minimum. Well, if you don't see it, download the Web Developer Firefox plug-in and you should get something like this (Information -> Document Size):
Notice! You should exclude WebResource.axd and ScriptResource.axd in the section for the HttpCompression handler in web.config. If you compress WebResource.axd, the standard .NET validating scripts and postback script will stop working. ScriptResource.axd is used by MS AJAX and has it's own compression module that will take care of the AJAX scripts. Typical the HttpCompression section should look like this:
<Flanders>
<HttpCompress compressionType="GZip">
<ExcludedPaths>
<add path="scriptresource.axd" />
<add path="webresource.axd" />
</ExcludedPaths>
<ExcludedMimeTypes>
<add mime="image/jpeg" />
<add mime="image/jpg" />
<add mime="image/gif" />
<add mime="image/png" />
</ExcludedMimeTypes>
</HttpCompress>
</Flanders>
Now you should should have reduced the bandwidth to serve the page. As mentioned earlier, this might not be the best approach for all sites. You need to consider whether you have enough CPU on the server to compress everything or if you have enough bandwidth to serve files uncompressed. If you are short on both, then you probably should consider buying new hardware or upgrade your bandwidth . Also remember that the files are decompressed and cached in the users browser. This is not the case on the server. Every page requested will be compressed after the page is rendered.
› Continue reading
The near future of TFS
Brian Harry who is the responsible manager for Team Foundation Server is blogging about upcomming features and fixes to TFS. It seems promising, but they should definetly release is soon, as a lot of people are waiting for the release. In particular the features of the Orcas version seems very welcome. I hope they will arrive sooner that soon.
Take a look at:
http://blogs.msdn.com/bharry/archive/2006/11/30/team-foundation-server-roadmap.aspx
Team System widgets
Accentient has a really nice list of Widgets for team System. Here you will find links to useful tools like the TFS Administration Tool, the TFS Power Pack and useful plugins like the Must Have Comments Check-in Policy. The list is growing, which is a good thing, because TFS has some missing functionalities, but you will probably find the missing parts on the list.
The LCD-TV integration is also listed, which is really cool
Check it out on: http://accentient.com/widgets.aspx
Presentasjonen fra NNUG [in Norwegian]
Takk for et fantastisk bra oppmøte i går. Mulig det var pga. Halloween og at folk følte seg truet til å komme
. Beklageligvis ble det fullt, og forståelig nok ville ikke brannansvarlig la folk sitte i midtgangen, så desverre måtte noen av de påmeldte deltakerne snu i døra. Totalt sett var det 140 påmeldte og det var plass til ca. 100 i auditoriet.
Uansett, her er presentasjonen jeg holdt i går. Hvis du skal kjøre Continuous Integration, så er det bare å laste ned eksemplet som jeg har lagt ut i denne artikkelen. Gjerne legg inn kommentarer hvis noe er uklart, så skal jeg forsøke å svare på det så godt jeg kan.
Working with WebTests
I have found very few articles on how to make customized WebTest with Visual Studio 2005 Team Edition for Testers or Visual Studio 2005 Team Suite. However, I bumped into this great article that show some of the more advanced techniques for authoring advanced and custom WebTests.
The article had excatly what I needed. My goal is to make a crawler that fetches most of the URL's on a website. This is useful for testing resources on the server when content is cached. Hitting the same page over and over again is not useful for testing memory resources. The test must fill the cache to it's limits and then we can see what performance the users will experience.
If the article is removed (or the server is down), here is the example code I used. I have of course modified it (removed links to external pages, javascripts, CSS/Images, etc.) to match the site I am running the test against, but the core code is the same.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.VisualStudio.TestTools.WebTesting;
public class LoopingCoded : WebTest
{
public LoopingCoded()
{
}
public override IEnumerator<WebTestRequest> GetRequestEnumerator()
{
// Issue a search for the term "Microsoft"
WebTestRequest request7 = new WebTestRequest("http://testserver/website/Search.aspx");
request7.ThinkTime = 20;
request7.Method = "POST";
FormPostHttpBody request7Body = new FormPostHttpBody();
request7Body.FormPostParameters.Add("txtSearch", "Microsoft");
request7.Body = request7Body;
yield return request7;
// Loop through each anchor tag in the search result and issue a request to each tag's target url (href)
foreach (HtmlTag tag in this.LastResponse.HtmlDocument.GetFilteredHtmlTags("a"))
{
WebTestRequest loopRequest = new WebTestRequest(tag.GetAttributeValueAsString("href"));
yield return loopRequest;
}
}
}
Resharper Team Blog
Can't live without it. Developing without resharper is like drinking a beer with a straw. It's possible, but slow. And to be honest refactoring in Visual Studio 2005 sucks. It's a lightweight implementation of refactoring, and it's slow. Compare "Find usages" in VS 2005 with resharper and I think you get the point.
Ok, resharper has a lot of bugs, but it will become more stable in the near future. Anyway, check out the new Team Blog for resharper.
Search
Knut Hamang
Recent Posts
Recent Comments
- Tim M on Passing an object to ObjectDataSource
- harin yadav.C on Html to Pdf in .NET
- harin yadav.C on Html to Pdf in .NET
- gautham on Html to Pdf in .NET
- How To Convert HTML To PDF With Image Tags Using iTextSharp | Top Online Trading on Html to Pdf in .NET



