Tuesday, December 9, 2008

Microsoft provide an open souce CMS

MS developed an open source CMS codenamed "Oxite". It's at alpha version stage.

From Microsoft’s description of Oxite:


“Oxite provides you with a strong foundation you can build upon - pingbacks, trackbacks, anonymous or authenticated commenting (with optional moderation), gravatar support, RSS feeds at any page level, support for MetaWebLog API (think Windows Live Writer integration made easy), web admin panel, support for Open Search format allowing users to search your site using their browser’s search box, and more - so, you can spend time on designing a great experience.”



Please go to here for some detail

Sunday, November 30, 2008

Free refactor in Visual Studio

There aren't many articles about build-in refactor tool in VS 2008. I find one post Refactoring In Visual Studio 2008. This can be used as a start point to this refactoring tool.

Also, DevExpress provided a free Refactor! for VS 2005. I found it originally from Free refactoring tools for ASP.NET code in Visual Studio 2005. Not sure if it works fine in VS 2008.

Thursday, November 27, 2008

Output GridView to Excel


To output GridView or DataGrid to Excel file, one can use:


  1. Use oledb classes to create and write data into Excel file

  2. If datasource is DataTable or DataSet, use writeXml method

  3. Use RenderControl method of Control class



Taking the latest way as an example

System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
htmlWrite.WriteLine("<table cellspacing=\"0\", rules=\"all\", border=\"1\">");
gvResult.RenderControl(htmlWrite);
htmlWrite.WriteLine("</table>");

System.Text.UnicodeEncoding encoding = new System.Text.UnicodeEncoding();

String fileName = Guid.NewGuid().ToString() + ".xls";
String path = @"c:\temp\";
File.WriteAllText(path + fileName, stringWrite.ToString(), encoding);

Data Binding Expression


One can use objects as datasouce and bind to it by using GridView control.

<asp:Label ID="lbNumber" runat="server" Text='<%#Eval("Number") %>'></asp:Label>


Here "Number" is a property of the datasouce object.



If the field of datasouce is a strong typed object itself, we can also use like this:

<asp:Label ID="lbProjectType" runat="server" Text='<%#Eval("ProjectType.Type") %>'></asp:Label>


"ProjectType" is a property of datasouce object and is an object which has a member called "Type".



If we want to do some complex work during binding, we can also do it at code behind. One approach is writing code in RowDataBinding or ItemDataBinding event handler, The other way is define a method and call it declaratively. Below is an example for the later:


<asp:Label ID="lbScheduledDate" runat="server" Text='<%# DisplayDate(Eval("ScheduledFrom"), Eval("ScheduledTo")) %>'></asp:Label>

Thursday, November 6, 2008

IIS can not access by anonymous account

Recently I encounter an issue. Windows anonymous account can not access local IIS. The security setting in IIS is correct.

After a couple of hours searching on internet. I find the cause. That's because my IUSR_computername doesn't has the right of "log on locally". So I go to:

controlpanel -> Admin Tool -> Local Security Settings -> Local Policies -> User Rights Assignment and find that Guest group doesn't have the permission of "Log on locally". Since IUSER_computername is memeber of Guest group. It doesn't have it as well.

I removed it from Guest group and add it to User group to make this account can be log on locally.

Auth Diagnostics 1.0 is a good tool to find IIS authentication issues. It can be downloaded here

Also, there is a good guideline here to help troubleshooting such issue.