Archive for Tips and Tricks

Silverlight: The First Rich Text Editor

This article has been written by Christoph Husse.

Many thanks to Michael for improvements and testing. He will provide his ToolBar for my rich text editor within the next days.

Download ~

1. The First Rich Text Editor (RTE) for Silverlight 2

Visit http://www.codeplex.com/richtextedit for source code and latest bug fixes.

Many people are waiting for a way to type rich text. Even if I think that Microsoft will bring out their own one, nobody knows how long to wait for and which features are included. My RTE ships with various common features and an extensive documentation. Please note that the whole thing is still in BETA state and there are some weird bugs on XP and different ones on Vista. It seems as if they are not caused by my component at all, because Visual Studio would notify me. So wait for the final version of Silverlight 2, until you use this component in any production environment! It is of course possible that some things are still undocumented or documented ones will not behave as expected. Don’t hesitate to report such incoherencies.

An incomplete feature list:

  • Copy/Paste formatted text between RichTextBoxes and copy/paste from/to clipboard of unformatted but macro-enabled text. This means in windows clipboard even things like emoticons will be kept.
  • You may insert line breaks, unordered lists and blockquotes.
  • You may use various keyboard selection features like End/ Home/ PageUp/ PageDown/ Left/ Up/ Right/ Down, Ctrl+A/ End/ Home, Ctrl+Shift+End/ Home/ Left/ Right, Shift+End/ Home/ PageUp/ PageDown/ Left/ Up/ Right/ Down and so forth…
  • Supports direct Unicode character input using “Ctrl”+[NumPad].
  • All silverlight font formatting is supported and even some more like SUP/SUB formatting.
  • You may define macros and a proper object class that should replace matching text, like emoticons…
  • In contrast to many other rich text editors, this one is fully real-time. That means no preview is required because the editor allows editing all things directly.
  • If you only use macros and IRichTextObject to extend the control, you will automatically get support for secure content serialization of all control elements. Content serialization also supports to reload content and edit it again.
  • Secure content serialization gets rid of any potential security leak when storing user typed formatted text on a server and presenting it to visitors, because it is fully verifiable.
  • You may restrict font formatting to a well defined custom subset. This allows you to ensure that all user typed input matches your needs or website design. (this feature is currently not implemented, but only prototyped)
  • Snapshots allow convenient access to formatted content and also Find&Replace with regular expressions for example…

If you want to report any bug or improvements, please write me a mail to LooneyLynn@gmx.biz. I will then add the issue to CodePlex issue tracker. You should also check if your bug isn’t already there…

1.1 A first look

The following screenshot shows some formatting and the use of macros (as emoticons are). It also uses a custom designed border and you can see that the inner content automatically gets realigned to fit into the outer border. You may also customize selection back- and foreground as well as cursor color.

A first look

There obviously are two uncommon features. The first thing is that you may insert any object derived from FrameworkElement into the text flow. The second thing is that such objects, as macros, are capable of assigning the formatting information, which will allow emoticons, for example, to also be underlined and background colored as the surrounding text is.

As you can see, there is a little problem with Silverlight’s interpolation feature. It leads to small separators which are visible after each char when font background is unequal to control background. For obscurity, this seems to be an issue of Vista, because under XP it is working as expected!
If someone has an idea how to work around this issue, please tell me!

1.2 Clipboard support

But it goes further. If you select such custom objects, for example the button, you will be able to copy/paste it with Ctrl+c/v or internal clipboard methods including all text formatting. If you select and copy macros to clipboard, they will be translated back to their text representation allowing to copy/paste macros between application boundaries, where in contract formatted text operations are restricted to the same application only. Clipboard operations are also supported, if the browser does not support it or the user has denied access. But then of course all operations are restricted to the current application.

This way you are able to thread custom objects as letters and also remove/overwrite them as usual text with backspace for example.

1.3 Future Features

Of course this control is not perfect. The following features will be implemented within the next months:

  • A XML scripting language to initialize rich text content in Expression Blend for example. This also eases management of multiple languages, because content and design are separated.
  • A way to wrap text around controls like known from Microsoft Office. Currently they are only inserted like a letter which limits capabilities of inserting images or any other kind of rich non-text content. But this feature is really far away from being simple, so don’t wait for it.
  • Non-editable XAML output which requires the XamlWriter that is currently not available.
  • Features that other developers may submit.

2. A tour through the demo

To understand how to use this component I really recommend stepping through the demo file. It utilizes nearly all features and shows some tricks to realize hyperlinks or Find&Replace with regular expressions using the abstract RTE interface. The following chapters refer to “RichText\Demo\Page.xaml.cs”.

2.1 Initialization

As RichtextEdit is derived from UserControl, you may use and initialize it as any other framework element.


RichEdit = new RichTextEdit();
RichEdit.AutoFocus = true;
RichEdit.InsertString(…);
RichEdit.OnSelectionChanged += new NotificationHandler(RichEdit_OnSelectionChanged);
RichEdit.OnContentChanged += new NotificationHandler(RichEdit_OnContentChanged);

MSNEmoticons.Apply(RichEdit);

RichEdit.RegisterObject(new SerializableButton(null));

The above code initializes the content with a test string and makes the control ready to receive two special events. This allows your code to get notified if either the selection or content has changed. Also the MSNEmoticons-Extension is applied which will replace common emoticons like “:-)” with a matching MSN-Icon. The last line is something special and will be covered later. All lines except the object creation are optional!

2.2 Updating a ToolBar


void RichEdit_OnSelectionChanged(object sender)
{
IsUpdating = true;

…
}

This event will update the whole Demo GUI according to the formatting at current selection. This method is very important for any useful ToolBar-Editor pair and you should try to understand what is going on there… The most important thing to mention is that all formatting properties like “RichTextEdit.FontAttributes” are set according to the current selection. That means you just have to read them out within the “OnSelectionChanged”-Handler and update your ToolBar properly.

2.3 Find&Replace

To find text, we need to utilize the RichTextEdit.Snapshot. This allows us to directly operate on string content what is not common when dealing with rich text:


private MatchCollection REGEX_Matches;
private Int32 REGEX_Index = 0;
private RichTextEdit.Snapshot REGEX_Snapshot;

private void BTN_Find_Click(object sender, RoutedEventArgs e)
{
REGEX_Snapshot = RichEdit.QueryText();

Regex Exp = new Regex(EDIT_Find.Text, RegexOptions.IgnoreCase |
RegexOptions.Multiline | RegexOptions.ECMAScript);

REGEX_Matches = Exp.Matches(REGEX_Snapshot.Text);
REGEX_Index = 0;

BTN_Replace.IsEnabled = true;
BTN_FindNext.IsEnabled = true;
BTN_FindNext_Click(null, null);
}

To realize the “Find Next” method, we just loop through all matches…


private void BTN_FindNext_Click(object sender, RoutedEventArgs e)
{
if ((REGEX_Matches == null) || (REGEX_Matches.Count == 0))
{
BTN_FindNext.IsEnabled = false;
return;
}

if (REGEX_Matches.Count <= REGEX_Index)
REGEX_Index = 0;

// select match
Match m = REGEX_Matches[REGEX_Index++];

REGEX_Snapshot.Select(CursorPosition.End, m.Index, m.Length);
}

As you can see a snapshot also allows us to select rich text based on string offsets.
If you also want to replace rich text, thing will get a little bit more complicated. Firstly we need to remove the text referred by the current match entry. Then we insert the replacement and select it.


private void BTN_Replace_Click(object sender, RoutedEventArgs e)
{
if ((REGEX_Matches == null) || (REGEX_Matches.Count == 0))
return;

if (REGEX_Matches.Count <= REGEX_Index)
REGEX_Index = 1;

// replace selection
Match m = REGEX_Matches[REGEX_Index - 1];
Int32 iStart = m.Index;
Int32 iLen = m.Length;

REGEX_Snapshot.Remove(ref iStart, ref iLen);
REGEX_Snapshot.Select(CursorPosition.Start, iStart, 0);
REGEX_Snapshot.InsertString(EDIT_Replace.Text);
REGEX_Snapshot.Select(CursorPosition.Start,
REGEX_Snapshot.SelectionStart - EDIT_Replace.Text.Length,     EDIT_Replace.Text.Length);
}

Even if this might look strange, it is a very consistent way to realize Find&Replace. Imagine there are custom objects between the letters that you wouldn’t know about. Such circumstances are handled within a snapshot and you don’t have to care about.

3. Secure content serialization

After a user has typed and formatted his text, you need to save it. My control provides a secure way to do this:


private void BTN_Serialize_Click(object sender, RoutedEventArgs e)
{
MemoryStream Buffer = new MemoryStream();
RichTextEdit.Snapshot Snapshot = RichEdit.QuerySelectionText();

Snapshot.Serialize(false, Buffer);

// convert to base64
LABEL_Binary.Text = Convert.ToBase64String(Buffer.GetBuffer(), 0,             (int)Buffer.Length);
BTN_Deserialize.IsEnabled = true;
}

As you can see, again the snapshot is involved; you need a snapshot of what you want to serialize. If your web server does not support binary serialization, just encode it to base64 as shown above. All formatting, all macros and all custom rich text objects will be included in such a serialization stream.
Deserialization works similarly:


private void BTN_Deserialize_Click(object sender, RoutedEventArgs e)
{
MemoryStream Buffer = new
MemoryStream(Convert.FromBase64String(LABEL_Binary.Text));

RichEdit.InsertDeserialization(false, Buffer);
}

3.1 Why is this secure?

It is secure because it is 100% verifiable. Secure does NOT mean that it is encrypted; you still have to use SSL for encrypted content transmission. Verifiability prevents you from a whole range of common attacks because it is simply not possible to store harmful serialization content on your server or invoke harmful operations when visiting your site.
In future versions, serialization will be improved to be compressed which will heavily reduce final stream size and though reduce your storage costs.

4. Custom rich text objects

Even if you may insert normal framework elements (FE), I don’t recommend it. A normal FE is not included in any kind of serialization and though not in clipboard operations. To allow FEs to be serialized, you have to create a class which implements the “IRichTextObject”-Interface. The following shows a rich text object wrapper around a simple button:


class SerializableButton : UserControl, IRichTextObject
{
private String m_Caption;
private Button m_Instance;

private SerializableButton() : base() { }

public SerializableButton(String InCaption)
{
m_Caption = InCaption;
}

public Int16 GetTypeID()
{
return 0x100;
}

public Boolean IsFocusable
{
get
{
return true;
}
}

public void Serialize(FrameworkElement InElement, BinaryWriter InTarget)
{
SerializableButton Button = (SerializableButton)InElement;

InTarget.Write((String)Button.m_Instance.Content);
}

public FrameworkElement Deserialize(
Boolean InIgnoreWarnings,
BinaryReader InSource)
{
return CreateInstance(InSource.ReadString());
}

public FrameworkElement CreateInstance()
{
return CreateInstance(m_Caption);
}

private FrameworkElement CreateInstance(String InCaption)
{
if (InCaption == null)
throw new InvalidOperationException();

SerializableButton Result = new SerializableButton();

Result.m_Instance = new Button();
Result.m_Instance.Content = InCaption;
Result.Content = Result.m_Instance;
Result.Width = 100;
Result.Height = 25;

return Result;
}
}

The above code combines a framework element and the interface. In general this is the easiest way, because during serialization and deserialization you will only get a reference to the FE and it’s your duty to find the proper rich text object interface.
The class implementing the interface should have a constructor that takes all parameters that are required to instantiate it. In our case we only need a caption for the underlying button. Those are also the parameters that should be serialized, because this way you only have to deserialize and pass them to the constructor to deserialize the whole rich text object.
The instance creator is something special. The rich text object (RTO) can be threaded as a wrapper around a normal framework element. It provides a way to keep all required data through serialization, to later recreate a technically equal instance. An RTO instance should always provide technically equal framework elements through “CreateInstance” but NEVER return any object twice. It should just ensure that all returned objects referring to the same RTO constructor parameters will behave and look the same.
Before all that you have to register the RTO with your editor as shown in initialization:


RichEdit = new RichTextEdit();
…

RichEdit.RegisterObject(new SerializableButton(null));

You don’t need to pass any parameters, because this RTO instance should just provide the “Serialize”, “Deserialize” and “GetTypeID” methods which can be threaded as static, but static methods are not supported with interfaces…
This technology is something hard to explain but it is very powerful if once understood. Please look at the demo and try to find out how it works.

Tips/Tricks: How to center Silverlight control on a webpage?

[Post written as of Silverlight 2 beta 1]

Question:

How can I center my Silverlight UserControl on the center of the web page (horizontally and vertically). To reproduce, create a new default Silverlight application in VS2008. I want that default xaml to appear in the center of the page, instead of the top left.

Source: http://silverlight.net/forums/p/11233/35791.aspx

My answer :

Centering something horizontally is so easy but vertically (especially for cross-browser). However, I found the CSS trick that works in any browser from this link. (Thanks to the original developer for this CSS trick.)

Silverlight

Let’s say your project name is “SL2Center” .

The following code is the default code from SL2CenterTestPage.aspx


<%@ Page Language="VB" AutoEventWireup="true" %>

<%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls"
TagPrefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" style="height:100%;">
<head runat="server">
<title>Test Page For SL2Center</title>
</head>
<body style="height:100%;margin:0;">
<form id="form1" runat="server" style="height:100%;">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div  style="height:100%;">
<asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/SL2Center.xap" Version="2.0" Width="100%" Height="100%" />
</div>
</form>
</body>
</html>

You change the width and height properties of Usercontrol to 300. And also, you add one TextBlock in that control.


<UserControl x:Class="SL2Center.Page"
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="300" Height="300">
<Grid x:Name="LayoutRoot" Background="Red">
<TextBlock Text="Silverlight Content" Foreground="Yellow" FontSize="30" FontWeight="Bold" VerticalAlignment="Center"  HorizontalAlignment="Center"/>
</Grid>
</UserControl>

The first thing that you need to do is that you have put the following CSS in <head> of SL2CenterTestPage.aspx.


<style type="text/css">
<!--

DIV.sl
{

position: absolute;
left: 50%;
top: 50%;
width: 300px;
height: 300px;
margin-left: -150px; /* half of width */
margin-top: -150px;  /* half of height */
background-color: #6699CC;
}

-->
</style>

I assume that the height and width properties of your xaml is 300. So, I set 300 to width and height in CSS.

Secondly, you have to set the class of DIV to the CSS class that we have created.


<div class="sl">
<asp:Silverlight ID="Xaml1" runat="server"
Source="~/ClientBin/SL2Center.xap" Version="2.0" Width="100%"
Height="100%" />
</div>

That’s all. You can run the application. You will see that the SL content is showing at the middle of web page. Cool, isn’t it? but one thing you should know is that if you want to change either width or height of XAML, you have to change the CSS again. I didn’t spend that much time for that but I hope you will get some ideas how you can customize it. Let me know if you have any problem or better solution.

You can download the sourcecode here.

Tips/Tricks: Where is DataGrid in Microsoft Expression Blend 2.5?

This post is just a tip for those who are not able to find DataGrid in Expression Blend 2.5 (March 2008 Preview). Laurent Duveau asked this question in Silverlight forum. I tried to find this solution and replied him in this post.

No datagrid in Blend 2.5? Yes, Silverlight Datagrid doesn’t show by default in the toolbox of Blend. The controls that you see on that toolbox are from System.Windows.Controls namespace. Silverlight Datagrid is NOT under that namespace. So, Datagrd is under which namespace? That control is under System.Windows.Controls.Data namespace. Okay. How to add Datagrid control to toolbox? Yes. This is the reason why I wrote this post. Please keep on reading further. I will tell you the step-by-step as below.

1. Expand the “Reference” node in Expression Blend to check whether System.Windows.Controls.Data.dll is already referenced in the project or not.

Blend Reference

2. If that dll is not there then right-click on the “References” node and select “Add Reference”

Add References

3. Go to the Silverlight SDK folder (e.g. C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Libraries\Client) . Select “System.Windows.Controls.Data.dll” to add as a reference in your Blend project.

data-dll-added.jpg

4. Click on “Asset Library” as shown in picture below

Click Asset Library

5. Click “Show All” and Select “Datagrid” in Asset Library

datagrid-in-asset-library.jpg

6. Finally, you got the Datagrid control on toolbox as you want.

datagrid-on-toolbox.jpg

Yes.. Good Job! you have successfully added the Datagrid control to Blend. :)

Tips/Tricks: Silverlight 2 (beta 1) Tools for Visual Studio 2008 Installation Error

Problem ~

An Error Has Occurred:
Silverlight Tools cannot be installed because one or more of the following conditions is true:

1. Visual Studio 2008 RTM is not installed.
2. The Web Authoring feature of Visual Studio is not installed.
3. A previous version of the Silverlight Runtime is installed.
4. A previous version of the Silverlight SDK is installed.
5. The Visual Studio Update KB949325 is installed.
6. A previous version of Silverlight Tools is installed.

To continue, please install or uninstall the appropriate products and run this installer again.

SL 2 Tool for VS 2008 2 ERROR

Solution ~

Short Answer: You are sure that all of conditions above are false but you are getting this error. Then, The shortest answer is “uninstall Silverlight 2 beta1 SDK” from your machine.

That’s all. You should be able to install after uninstalling. but If you want to read more details, please keep on reading further.

Detailed ~

Step #1. Install Visual Studio 2008 release version or RTM version

You have to install the release or RTM version of Visual Studio 2008 in your machine. Your Visual Studio should be Professional Edition or Standard Edition or Team System. You can’t use VS 2008 beta or Express version.

Step #2. Install the Web Authoring Component of Visual Studio

The Web Authoring feature of Visual Studio

You need to check whether you have Microsoft Visual Studio Web Authoring Component installed in your machine or not. If you have installed Visual Studio 2008, you already have that web authoring component installed. but just in case you accidentally remove that component, you can run WebToolsCore.exe to install that component manually. The setup fiel is located under WCU\WebToolsCore of VS DVD. If you are not sure about what VS Web Authoring Component is, you can read this post.

Step #3. Remove the Visual Studio Update KB949325 if it’s installed

You have to remove that Visual Studio Update (KB949325) from your machine.

If you are a Windows Vista user, please go to “Control Panel” and open “Programs and Features”. Then, Click “View installed updates” and find “KB949325″.
view-install-update.gif

If you are XP users, go to “Add and Remove Programs” and select “Show Update”. And find “KB949325″ in the list.

Step #4. Uninstall all of the previous versions of the Silverlight Runtime/SDK/Tool

You have to uninstall all of the previous versions of Silverlight runtime/SDK/Tool from your system.

Uninstalling is very simply. but sometimes, you might face some weird problems. One of my friends faced one weird problem when he tried to uninstall the previous version of Silverlight. He installed “Silverlight 1.0 SDK VS 2005 template” in his machine long time back. The time when he installed that SDK, he had VS 2005.

sdk-template.jpg

but after sometime, he removed VS 2005 from his machine. Now, he wanted to remove SL 1.0 SDK but he couldn’t. The message below kept on showing when he tried to uninstall.

sl-sdk-10.jpg

So, I suggested him to use Windows Installer CleanUp Utility to remove that SDK and he did it.

ms-clean-up-remove.jpg

Note: I would like to suggest you to use CCleaner to scan your registry and fix all issues after removing SL 1.0 SDK from your machine.

Step #5. Uninstall Silverlight 2 (beta1) runtime, SDK, Tool for Visual Studio 2008

Please uninstall Silverlight 2 (beta1) runtime, SDK, Tool for Visual Studio 2008 in case you have installed before facing this problem.

Step #6. Install Silverlight 2 (beta1) runtime

Now, you can install Silverlight 2 (beta1) runtime. (It’s just for the sequence of installing. That’s why I asked you to uninstall SL2-related things first.)

Step #7. Install VS 2008 Web Development Hot-Fix

You can download this hot-fix from this link. then, install it in your machine after installing Silverlight 2 runtime.

Finally,

Now, you can run silverlight_chainer.exe again.I hope you should be able to run the setup successfully. Feel free to let me know if you have any problem in installing SL 2 Tool.

Issues after installing Silverlight 2 Tool for VS 2008

#1: ‘Microsoft.VisualStudio.Web.Silverlight.IVsSilverlightService’ error

If you are getting one of the following error, you have by-passed the validation of Silverlight 2 Tool installer by extracting (winrar-ing) the silverlight_chainer.exe or following this post. You have to follow 7 steps that I mentioned above to install Silverlight 2 Tool firstly. If you are able to install that tool, the following error will be disappeared.

vs-2-err.jpg

OR

error.jpg
#2. The project type is not supported by this installation

error.jpg

Run devenv.exe /resetskippkgs in case you got this error. (Thanks to BradleyB for this post.)

Bulk Image Downloader for Wordpress Users

A tool for downloading images from your Wordpress.com blog to your local machine. It is also an example of how to use XML RPC service in C#.

Executable : WpBulkDownloader-Alpha-Executable.zip
SourceCode : WpBulkDownloader.zip

Contents

  • Introduction
  • Background
  • Software Requirements
  • How to use
  • How it works
  • FAQ

Introduction

This is a tool that helps you to download all of your images that you posted in your blog. This tool is created especially for Wordpress.com users but it will support all other blogging softwares in future. You will definitely need this tool when you want to move your blog from wordpress.com to self-host.

WP Bulk Image Downloader (Alpha) for Wordpress Users

Background

My blog was hosted on Wordpress.com last year. I had too many images uploaded in my free space. When I wanted to move my blog to self-host, I noticed that there is no way to bulk-download all of my images from Wordpress account to my local disk. I didn’t want to copy each and every images manually so I wrote this tool that can scan each and every urls from my blog and create the directory based on the URL. And then, download them into my local harddisk. It’s just 2 hours program that I wrote at that time. So, I’m sure that there won’t be all features that you want in this program. But don’t worry. Just drop a comment in this post. I will add the feature that you want in next release.

Software Requirements

How to use it?

The steps are very simple.

  • Configure your blog in Bulk Image Downlader. Click “Options” and fill your blog URL, user name and password as picture below.

WP Bulk Image Downloader - Options

  • Click “OK” button to save your configuration and close the dialog
  • Click “Get Files” button to get the list of image URLs from your blog. (You may need to wait a few minutes while retrieving the list of images from your blog.)
  • After retrieving the list of Image URL, you can click “Download” button to download the images to your local disk. (You may need to wait a few minutes while processing. )
  • After that, you can check all of your images in “Downloaded Images” directory.

How does it work?

Note: This is for those who like to read the sourcecode and want an explanation about codes. If you are just a normal user, you may skip this section.

Firstly, the program will read the user name, password and blogurl from config file. It will append “xmlrpc.php” which is the standard XML RPC interface for Wordpress at the end of blogurl string. Then, it will invoke getRecentPost() API of wordpress. I used opensource XML-RPC.NET library in this sample. As there is no getPosts() API in xmlrpc.php, we have to use the alternative method (getRecentPost() API) for retrieving the posts from the blog. The max number of posts is set to 1000 in the program. If you have more than 1000 posts in your blog, you probably need to change the default value.

If the authenticating is successful then we will get the list of posts from the blog. So, we have to filter the URL of images from the contents. Initially, I was thinking to filter <img> tag from the content. But there are some cases that we used big image in <A> tag and small images in <img> tag. So, I decided to filter the <img> tag and <a> tag from the contents based on the extensions (*.jpg, *.png, *.gif) by using regular expression. After that, I shows the list of URLS in ListView.

When the user clicks “Download” button, I start downloading the image one by one. (Note: I used C# downloader class which is written by Shailen Sukul in this example. ) Based on the URL, the program will create the directory accordingly. For example, If the image URL is “http://your.wp.com/2009/09/image1″ then the program will create the directories like “09″ folder under “2009″ folder under “/Downloaded Images/” folder. So, you can easily upload all of your images to your new host via FTP.

That’s all about how Bulk Image Downloader works. If you have any question, please let me know.

FAQs

1. Can you make the better UI for this program?

Yes. Of course. I’m thinking to change this Windows Form to WPF version so that you will definitely get the better UI for this program.

2. The form is freeze while downloading the images. Why?

Sorry about this issue. For the time being, all processes are running in single thread so that UI will be freeze while processing. I will separate the UI and logic into different thread in next release.

3. Can I request new feature?

Yes. Of course. This is the main reason why I released it as alpha. Feel free to drop a comment in this post. I will make a list of feature requests and will be added in next version.

Codeproject Highlight

Do you want to be informed the best stuffs of Codeproject every months? I have one good news for you. I’m gonna launch one new program called “Codeproject Highlight” started from this month in my blog. In this program, there will be there parts such as news, the best articles and the best posts in CP forum (mostly are from ASP.NET, Web development and C#. ).

The main reason why I start this program is that it saves your time for reading all of latest articles from CP’s feed and tracking all questions and answers from Codeproject forum.

News

Site Upgrading

The whole Codeproject site has been upgraded from Classic ASP to ASP.NET version with a lot of improvements . This is really big changes which is done during 8 years of running. As this site has really huge amount of traffic, it’s very hard for them to upgrade this site with new version. However, the CP development team has done the great job to upgrade the whole site successfully. Congratulation! CP team

Chris shared a few interesting things here ~

For those interested here are some whacky and amusing things we found:

  • SQL Server, IIS and the ASP.NET framework are possessed.
  • Using development settings instead of production settings is a Bad Thing.
  • Storing session state in a SQL database can be a performance killer. Especially when the database is an old P4 test harness machine 40 km away from the webserver. That was an interesting experience in scream therapy.
  • Always check your indexes. Especially the ones that absolutely positively are not and cannot be fragmented. They will be the ones most in need of attention.
  • 20,000 users hitting your application is wonderful load testing. We did load test but our testing machines did not generate the load you guys can generate
  • no matter how many ways you check code there’s always an angle that you haven’t looked at. We’re finding errors in 10 mins of being on that we couldn’t find from 3 months of beta testing. This is just nature.

The Best Articles

  • Silverlight 1.1 Fun and Games by Sacha Barber

    Silverlight Game and Fun

    Sourcecode : Download Source

    Note: This is an award-winning article of Visual Studio 2008 Competition.

  • Silverlight Alien Sokoban by Daniel Vaughan

    A fun Silverlight implementation of the game Sokoban. Contrasting Silverlight 1.1 and WPF, while showcasing some new features of C# 3.0, Expression Design, Expression Blend, and Visual Studio 2008.

    Silverlight Alien Sokoban

    Sourcecode : Download Source

  • Build Google IG-like Ajax Start Page by Omar Al Zabir

    Build a start page similar to Google IG in 7 nights using ASP.Net Ajax, .NET 3.0, Linq, DLinq and XLinq.

    Google IG

    Sourcecode : Download Source

    Demo : Ajax Web Portal

  • WCF / WPF Chat Application by Sacha Barber

    How to create a peer-to-peer chat application using Windows Communication Foundation

    Free Chatting Client in .NET

    Sourcecode : Download Source

  • ASP.NET Popup Control by Tomas Petricek

    Highly customizable JavaScript popup control for web page wrapped in ASP.NET custom control.

    ASP.NET Popup Control

    Sourcecode : Download Source

Links

The best posts in Codeproject forum

  • How to store the password in Database? Encrypting Vs Hashing, Salt

    This is a discussion about storing the password in database. As the user authentication used to be a part of almost every software system, the developers should have good understanding about how to store the password in database. We have discussed about encrypting vs hashing, adding salt or adding the user name after the password and etc.

    Summary

    • Don’t use encryption/decryption for password.
    • Don’t need to append the user name to the password.
    • Hashing the password with random salt (SHA2 might be the best for hashing.)

    You can read about it in the link below.

    Read More ~ guidelines on password encryption

  • Does the System.Deployment namespace cover a great deal of scenarios?

    I have been asked this question regarding ClickOnce deployment in CP forum. As I’m using ClickOnce APIs on SCSF (Smart Client Software Factory) project, I found a few missing things in System.Deployment namespace. The following are the things that ClickOnce can’t handle.

    Summary

    • No way to get the list of latest modules
    • The version of the whole application need to be updated if we wanna update just one module
    • ClickOnce doesn’t care about the version of assemblies.
    • DownloadFileGroup (”") works only if “optional” is checked. There is no way to download the group of file by force

    Read More ~ An application that will get the updates from server automatically

  • ADODB.DataTypeEnum.adBigInt problem “Bad variable type!” in Windows 2000

    One people who are using ADODB in .NET asked the question below in our CP forum.

    The identity field of one of my SQL DB tables is a bigint, using ADODB to query the DB based on this bigint works fine in my XP machine, but gives me a “Bad variable type” error when I use my app in a W2000 machine.

    The W2000 machine has every service pack issued by MS, what could be the problem?

    Something works fine on XP doesn’t work on Windows 200 is very strange issue. As I never use ADODB (something that we used for VB6 projects in old days ) in .NET, I don’t have that experiences. The possibilities that I think of at that time did solve his problem.

    The trick is that casting the original datatype (long datatype in his case) to double datatype. :) Honestly, I’m not so sure why we need to do this but it did solve the problem.

    
    Cmd.Parameters.Append(Cmd.CreateParameter("TransId", ADODB.DataTypeEnum.adBigInt, 1, , CType(iTransId, Double)))
    

    Read More ~ In XP works fine, W2000: Bad variable type!

Okay. That’s all for now. This is just a taste of new thing in my blog. What do you think? Is it interesting? As this program is just started, your feedback is highly appreciated. I think that there are a few area that I can’t add in this post. Based on the feedback from all of you, I will make this program better and interesting.. If you like it, don’t forget to subscribe my feed ( http://michaelsync.net/feed ).

Thanks.