Tuesday, December 14, 2010

Turn on Friendly URL

In the file /config/UrlRewriting.config one can place rules for rewriting URLs. Just add a rule like this.

virtualUrl="^~/blog/tag/(.*).aspx"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/blog.aspx?filterBy=$1"
ignoreCase="true"
/>


Refer to this post for more info.

Thursday, October 14, 2010

worldpay integration

The tricky part of the worldpay integration is about the redirecting. There is no way for you to specify where to redirect the user to a destinate page when the payment is completed.

Instead worldpay use the concept of proxy calling, which will call you page indirectly, in fact it is the Payment Response URL that you specify in installations after you login to worldpay page.

IF you didnt set the checkbox for [Enable the Shopper Response], user will not see the redirect.

In conclusion, the trick is to use point the Payment URL to PAGE A, then in PAGE A you include

< meta http-equiv=' refresh ' content=" 0 ; url = http://YOUR FINAL URL" / >

You will show you thank you message in your final URL.

Last point is to make sure you captured the transaction information that pass to you from worldpay in the Payment Response URL page.

Refer to this article http://harrybailey.com/2010/02/worldpay-response-url-shopper-return/.

Tuesday, May 18, 2010

How to dynamically apply globalization on keyword retrieved from various sources

One of the common requirement is to apply globalization on the keyword that retrieved from sql database to make your content dynamic.

The below is the example, where output is the KEYValue of the KEYWORD in ResourceCLASSNAME

string output = HttpContext.GetGlobalResourceObject("ResourceCLASSNAME", "KEYWORD").ToString();

Monday, May 17, 2010

Google Mapl Play back

1. very good example
2. complex example
3. click to show the point example
4. example in flex

Wednesday, May 5, 2010

motivating clips from Steve Jobs

This is one of the must watch motivating video

Friday, April 30, 2010

Google Map API V3 vs V2

Adding Marker in V2:
map.addOverlay(marker);

Adding Marker in V3:
marker = new google.maps.Marker( { position: point, icon: icon1, title: sTitle, map: map } ) ;

Removing Marker in V2:
map.removeOverlay(marker);

Removing Marker in V3:
marker.setMap(null);

Actually there are many more difference, but this post only highlighted basic one.

Wednesday, April 28, 2010

RadWindows pop up position

Want to control your radwindows pop up position, check out this post to save your life.

padding zero

Sometime when you need to append padding zero for a numeric figure. e.g. 0001, 0002 .

You might think to write your own 'sweet' logic to format the string. The good news is, .net out of the box gives you this feature.

string.Format("{0:00000}", yourIntegerValue);

unable to retrieve textbox value in server side when textbox is set readonly

One of the common UI design is to have a couple of textbox and you might want to prevent it from user modifying the value. And the easiest wayout is to set the textbox as readonly or disabled.

Unfortunately, you wont be able to get these 'disabled' or 'read-only' textbox value from server side.

One of the workarounds is to set the readonly condition during runtime instead of design time in asp.net page.

txtbox1.Attributes.Add("readonly", "readonly");

Page load event is fired twice with user control

One very strange behaviour that i noticed is that, page load event is fired twice. It started with page load and then followed by postback.

What I have:
1. Ajax Page
2.User Control
3.Asp.net C# page

After going through many testing and debugging, i realize that after setting the auto event wire up as false, everything is back to 'normal'.

To know which control trigger the postback, apart from using ___EventTarget to track, refer to this post, it contains a more comprehensive approach.

Page AutoEventWireup="false"

Thursday, April 22, 2010

Global RESX for chinese language

You might encounter the following error when you try to use chinese RESX file.

The namespace 'Resources' already contains a definition for 'Resource' Resource.CN

the reason is because the culture info is wrong.

refer to this post for more info. For basic knowledge, refer to this post

Animated scroll to anchor/id function with jQuery

This feature is useful especially when you need to maintain the page position after browsing from other pages.

A quick win will be using anchor in the url, but the catch is if you are using controls like telerik grid ajax postback, the anchor point #XXX in your url will be subtracted and you won't be able to do what you want.

One more point is that it is good to use this function in $(document).ready(function ()) instead of pageLoad() so that it only move to your position once when page is loaded not ajax postback.

checkout this blog for more information.

Tuesday, April 20, 2010

vss 2005 on vs 2010

Before you get your hands dirty on vs 2010, make sure you have the patch to make vss 2005 works with vs 2010, or else you have to setup TSF.

Download this patch.

Thursday, April 1, 2010

label on googlemap marker

This open source for labeling on googlemap marker is very useful.

Checkout the example from here, where you can inject html code to show your label.

Friday, March 26, 2010

Project Management cum invocing system

This application is cool !

Mapping Enums to Strings and Strings to Enums in .NET

Came across this article on how to convert enums to string and vice versa in .net, which is pretty interesting to share.

'Clean' Sites

1. This site is very clean and 'light'
2. a lists of 'clean' site

jquery links

1. dialog box
2. validation

execellent icons site !!!

1. iconfinder
2. list of 'free' resources

Wednesday, March 24, 2010

Error Msg : No property or field 'xxxID' exists in type 'DataRowView'

If you hit this error when you are using radgrid with objectDataSource, please disable linqExpression by setting EnableLinqExpressions = "false" in the Radgrid properties.

Tuesday, March 23, 2010

telerik grid filtering feature

Telerik grid provide a good feature on filtering. There are two ways you can do filtering,

1. use out of the box filter feature by setting AllowFilteringByColumn="true"
2. set FilterExpression for grid.MasterTableView parameter with (iif(colName== null, \"\", colName).ToString().Contains(\"filterValue\"))

Monday, March 22, 2010

jquery toggle effect

To build the UI effect like this, we can extend from the below simple example. Use the 'green' code to hide/ show a section using a button. Use the 'orange' code to toggle the button orientation.

$("#buttonZone").click(function() {
$("#searchDiv").slideToggle(600);

});

$("#buttonZone").toggle(
function() {

$(this).removeClass("buttonZoneHide");
$(this).addClass("buttonZoneShow");

},
function() {

$(this).removeClass("buttonZoneShow");
$(this).addClass("buttonZoneHide");

});

how to access your asp.net controls in jquery.

$(document).ready(function() {
var id = " < % = chklstFilesAvailable.ClientID % > ";
var chklist = $("#" + id);
var btnId = " < % = btnDownload.ClientID % > ";
var button = $("#" + btnId);
//reusable show/hide button wiring
wireButtonShowToCheckListBox(chklist, button);
});

function wireButtonShowToCheckListBox(chklist, button) {
chklist.find('input:checkbox').each(function() {
var cb = $(this);
cb.click(function() {
var hit = false;
chklist.find('input:checkbox').each(function() {
var checked = $(this).attr('checked');
if (checked)
hit = true;
});
if (hit == true) {
button.show();
} else {
button.hide();
}
});
});

}

Refer to this article for more details

Friday, March 19, 2010

how to find out what caused the postback

if you are using ajax panel to ajaxify yr web page, you might notice that postback happen for any trigger happens within the ajax panel, this includes date selection in the calendar, button click event and etc.

you might want to find out which control causes the postback to do yr code handling.

the key is to use string control = Request.Form["__EVENTTARGET"]; in page_load event.

The [control] will be null during page load, if the postback is caused by button1, [control] will have the value of button1.

Checkout this artcile to find out more

Wednesday, March 10, 2010

how to execute javascript after ajax request is completed

If you are using the microsoft ajax framework, you might encounter a scenario where you need to execute javascript after your ajax call is completed.

The key is to add your javascript method using

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

put the javascript method that you need to execute in EndRequestHandler function.

Checkout this very useful post.

Saturday, March 6, 2010

power of jquery - 1

1.Checkout this amazing effect using jquery for your navigation

2.This article shows you the dynamic tabs using jquery

3. This article shows an alternative way to show validation error

4. Wizard like form filling experience

5. This article shows dropdown menu navigation using jquery

6. This article shows very good effect message box effect to show after you saved something

7. This article shows better UI experience by highlighting the row during data entry into the form.

Checkout all the jquery tutorial from Janko, you will be impressed.

Monday, March 1, 2010

CSS Message box 101

This article shows different permutation on message box using div


Look at the trick number 10 in this post, to highlight the navigation item of the user's location in the website, to help users orientate themselves.

tricky issue using profile in asp.net 3.5

This problem will take u at least one hour to figure out why the behaviour in asp.net 2.0 and asp.net 3.5 is different.

Checkout this article to use profile in asp.net 3.5.

Sunday, February 28, 2010

10 UI Design fundamental

came across a good article on UI design

article on 12 useful technique for good UI Design

article on 11 great UI design resources

Thursday, February 25, 2010

Test Driven Development

Checkout this article to learn how to use VS Test Project to apply test driven development methology in your project. This article highlights the details on data driven test case

One point to note is that, it is possible to keep your test data in database, which is very useful in doing testing, instead of coding on the logic for your test data, you can leverage on the framework.

[TestMethod]
[Owner("Mark Michaelis")]
[TestProperty("TestCategory", "Developer"),
DataSource("System.Data.SqlClient",
"Data Source=.\\SQLEXPRESS;AttachDbFilename=\"";Integrated Security=True",
"LogonInfoTest",
DataAccessMethod.Sequential)]
public void ChangePasswordTest()

Sunday, February 7, 2010

Excellent Linq Example

This webcast describe the linq concept clearly, it is very useful for beginner.

After you see this webcast, it is very likely you can unleash the power of LINQ-to-sql

Saturday, February 6, 2010

Good example to describe delegate

Refer to this webcast from jennifer to have a better understanding on delegate

it is useful when you want to trigger method B or method C from method A, you can consider to use delegate to represent method B, C, see this video to find out more.

Wednesday, February 3, 2010

Full-featured customer portal

Looking for how to build a full feature portal for scratch. Check out this video from asp.net.

It shows you how to do C.R.U.D. for a table in sql and datagrid using sqldatasource, and also the login control.

Thursday, January 21, 2010

wonder if bizspark msdn license can be used for production environment.

The answer is YES.


Find out more from here in appendix A

Wednesday, January 20, 2010

Error : Sequence contains no elements when you execute query that return null

In this statement if Trans.param1== param1Value returns nothing, you will hit the error above.

Class1 objClass1 = _db.Class1.First(Trans => Trans.param1== param1Value);

To prevent this, you need to use 'FirstOrDefault' instead

Class1 objClass1 = _db.Class1.FirstOrDefault(Trans => Trans.param1== param1Value);

How to pass Guid variable to ObjectDataSource ?

I Spent one day to find out how to pass guid variable to objectDataSource, the error encoutered is

"Object must implement IConvertible"

The solution for this is to use


"< name="myGuid">" instead of

"< name="myGuid" type="String">"

Find out more from here

Friday, January 15, 2010

ashx

Just discover what is ashx in asp.net, it is nothing but the httphandler that we used in MOSS.

Creating a new ashx, is actually creating a class that inherit from IHttpHandler. Instead of loading xml from page load event in typical asp.net web form, ashx could be the best option for you to do the same tasks.

Example,


public void ProcessRequest (HttpContext context)
{
context.Response.ContentType = "text/xml";
context.Response.ContentEncoding = System.Text.Encoding.UTF8;

string sXml = BuildXMLString(); //not showing this function,
//but it creates the XML string

context.Response.Cache.SetExpires(DateTime.Now.AddSeconds(600));
context.Response.Cache.SetCacheability(HttpCacheability.Public);
context.Response.Write( sXml );
}

Thursday, January 14, 2010

jquery + VS 2008 SP1

Ever wonder how to enable jquery intelliSense in VS 2008 ? very simple.

0. VS SP1 is installed
1. Download the KB946581 from here
2. Download jquery from here and documentation from here
3. Install the KB

This is it, very simple. The next question is why jquery, checkout this post on how to call .net webservice using jquery


Useful resources

Download for Visual Studio 2008 SP1

Download for .net 3.5 SP1

How to perform autoComplete