Kim's Blog
Tuesday, October 30, 2012
Saturday, October 13, 2012
How to add ASP.NET 4.0 as Application Pool on IIS 7, Windows 7
- Open your command prompt (Windows + R) and type cmd and press ENTER
You may need to start this as an administrator if you have UAC enabled.
To do so, locate the exe (usually you can start typing with Start Menu open), right click and select "Run as Administrator" - Type cd C:\Windows\Microsoft.NET\Framework\v4.0.30319\ and press ENTER.
- Type aspnet_regiis.exe -ir and press ENTER again.
Saturday, June 30, 2012
RadGrid - Export to Excel with Custom Currency Format
Luckily, based on some suggestions on both 2 site, I solved this problem (phew, God bless me)
Below is all steps to get it (I assumed we can format "$ xxx.xx USD" on grid)
Step 1:
Register the ExcelExportCellFormatting event for grid
protected void grid_ExcelExportCellFormatting(object source, ExcelExportCellFormattingEventArgs e) { var item = e.Cell.Parent as GridDataItem; var hdfCurrency = item.FindControl("
hdfCurrency
") as HiddenField;
var format =
FormatCurrencyWhenExportToExcel(
hdfCurrency.Value);
switch (e.FormattedColumn.UniqueName) { case "TotalPrice": var hdfTotalPrice = item.FindControl("
hdfTotalPrice
") as HiddenField;
// Assumption the
hdfTotalPrice.Value = "25.00"
or "-25.00";
e.Cell.Text =
hdfTotalPrice.Value
; e.Cell.Style["mso-number-format"] = format; break; } }
Step 2:
Write the FormatCurrencyWhenExportToExcel function
public static string FormatCurrencyWhenExportToExcel(string currency)
{
var regionInfo = new System.Globalization.RegionInfo(Globals.GetCurrencyCulture(currency).Name);
var format = @"\0022" + regionInfo.CurrencySymbol + @"\0022\#\,\#\#0\.00\ \0022" + regionInfo.ISOCurrencySymbol + @"\0022";
return format;
}
That's all.
Enjoy your code.
We can reference these sites:
http://niallodoherty.com/post.cfm/basic-html-to-excel-formattinghttp://agoric.com/sources/software/htmltoExcel
http://cosicimiento.blogspot.com/2008/11/styling-excel-cells-with-mso-number.html
http://www.telerik.com/help/aspnet-ajax/grid-html-export.html
Tuesday, March 13, 2012
Searching special character (e.g. %,_) with .NET and Stored Procedure
searchText = searchText .Replace("%","[%]"); //same with "_" character
LIKE '5[%]' = 5%
LIKE '[_]n' = _n
LIKE '[a-cdf]' = a, b, c, d, or f
LIKE '[-acdf]' = -, a, c, d, or f
LIKE '[ [ ]' = [
LIKE ']' = ]
LIKE 'abc[_]d%' = abc_d and abc_de
LIKE 'abc[def]' = abcd, abce, and abcf
Tuesday, June 14, 2011
How to add a Uninstall option in Visual Studio Setup project without writing code
1) In the Setup Project –> File System windows –> Right Click “File System on Target machine” –> add a Special Folder, select System Folder;
2) Into this system folder Add a file. Browse for msiexec.exe from local System32 folder and add it. Override default properties of this file as follows:
Condition:=Not Installed (make sure you put ‘Not Installed’ exactly like that, same case and everything), Permanent:=True, System:=True, Transitive:=True, Vital:=False.
3) Create a new shortcut under the ‘Users Program Menu’, Set Target to the System Folder which you created in the step 1. and point it’s at the msiexec.exe. Rename the shortcut to ‘Uninstall Your Application’. Set the Arguments property to /x{space}[ProductCode].
4) Build the project, ignore warning about the fact that msiexec should be excluded, DONT exclude it or the setup project wont build.
The ‘Not Installed’ condition and Permananet:=True ensure that the msiexec.exe is only placed into the system folder as part of the install IF it doesn’t aready exist, and it is not removed on an uninstall - therefore it;s pretty safe to ignore that warning and just go for it.
Wednesday, April 13, 2011
Solving RAW issue with WCF and content-type
1 using System.ServiceModel.Channels;
2
3 namespace AtlanticGateway.GatewayComponent
4 {
5 public class RawContentTypeMapper : WebContentTypeMapper
6 {
7 public override WebContentFormat GetMessageFormatForContentType(string contentType)
8 {
9 if (contentType.Contains("text/xml") || contentType.Contains("application/xml"))
10 {
11 return WebContentFormat.Raw;
12 }
13 else
14 {
15 return WebContentFormat.Default;
16 }
17 }
18 }
19 }
25 <service behaviorConfiguration="NotificationServiceBehavior"
26 name="AtlanticGateway.GatewayComponent.Services.NotificationService">
27 <endpoint behaviorConfiguration="web" binding="customBinding" bindingConfiguration="RawReceiveCapable"
28 contract="AtlanticGateway.GatewayComponent.Message.INotificationService" />
29
74 <bindings>
75 <customBinding>
76 <binding name="RawReceiveCapable">
77
78 <webMessageEncoding webContentTypeMapperType=
79 "AtlanticGateway.GatewayComponent.RawContentTypeMapper, AtlanticGateway.GatewayComponent,
80 Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
81 <httpTransport manualAddressing="true" maxReceivedMessageSize="524288000"
82 transferMode="Streamed" />
83
84