October 26, 2012
@ 12:03 PM
IE8 only...
if you give TD a class,,,

<td class='col1'>---</td>

it will lost the "text-align" defined in parent element.
you need add " text-align: inherit;" to make it align left or right...

very difficult to find the right solution of this issue.

Categories: WebDesign

I got requirement to display all fields in one page to less than 20 characters,  and display full length when mouse over on tool-tip.
I decide to use jQuery implement this, Below is partial code in UserAdminView namespace..
 SetUpAccountInfo: function () {
            var limit = 20;
            var targets = $(".account-info dd").not("dd.nolimitdisplay");
            targets.each(function () {
                UserAdminView.SetUpDisplayLimit($(this), limit);
        SetUpBaseService: function () {
            var limit = 50;
            var targets = $(".base-service dd");
            targets.each(function () {
                UserAdminView.SetUpDisplayLimit($(this), limit);
            // UserAdminView.SetUpDisplayLimit(target, limit);
        SetUpDisplayLimit: function (target, limit) {
            var fullMsg = target.html();
            if (fullMsg.length > limit) {
                target.html(fullMsg.substring(0, limit) + "...");
            target.attr('title', fullMsg);

Categories: JQuery

A simple test,
     url: "http://localhost:45166/userAdmin/UserAccountInfo/?child=true&json=true",
     dataType: 'jsonp',
     success: function(json) {

         //jsonp return a javascript
         // callback({json:value})
     error: function() {


in the Controller

return a javascript as ActionResult:
return JavaScript("alert({'TEST'})");
the javascript can be run in the client site.

Categories: JQuery | MVC

October 4, 2012
@ 01:15 AM

Notes of read book "clean code"  by Robert C. Martin

SRP: Single responsibility
DRY: Don't repeat yourself
OCP: open close principle

1. Switch break the SRP and OCP, should limit it in bottom and factory.
2. Try catch should keep it small ,and no code after try catch block
3. Use exception in stand of ErrorCode
4. Each function should has only one return...try avoid  break, continue, never use goto
5. one parameter is better than two parameters and better than three or more
6. Make sense Name and comments
7. First write the code as you think, then refactor to follow the principle
8. Don't return or pass null, empty list is much better
9. Put Error handle code out side the main logic

Something in the book I don't agree is for Name convention,
he don't like name interface with prefix 'I', and don't like put the type in classname such as AbstractProduct or Iproduct.

But I think that make our life easier when we code...if you need a interface,  With the help of Intelli come with VS or ReSharper ,you type 'I', it will jump out, if you need a Enum...type Enum..all Enum named start with Enum will list for you to choice.

Categories: Agile | C# | OODesign

October 2, 2012
@ 11:46 PM
MVC Techniques with jQuery, JSON, Knockout, and C#


also need check this:



Categories: JQuery | MVC

October 2, 2012
@ 11:27 PM

Base on MVC definition from msdn http://msdn.microsoft.com/en-us/gg592073:

  • Models: Model objects are the parts of the application that implement the domain logic. Often, model objects also retrieve and store model state in a database.
  • Views: Views are the components that display the application's user interface (UI). Typically, this UI is created from the model data. An example would be the edit view of Albums that displays text boxes and a drop-down list based on the current state of an Album object.
  • Controllers: Controllers are the components that handle user interaction, manipulate the model, and ultimately select a view to render the UI. In an MVC application, the view only displays information; the controller handles and responds to user input and interaction.

So Create a ViewModel for each Views, ViewModels should be a DTO or Plain Object.   and Models are Factories to Generate ViewModels.

The MVVMC should be like this:

for example UserContacts page:

UserContactsController ->UserContactsModel->UserContactsViewModel->UserContactsView

Controller ask UserContactModel for UserContactsViewModel and fill the UserContactsView and return it.

and there is another View Model or domain object UserContact.

UserContactsViewModel is Model of UserContactsView,

UserContactsViewModel has something like List<UserContact>

there should be couple of helpers can be called by UserContractsModel.

Categories: Asp.net | MVC

Create a no Form Wizard for children template, use static properties to take value from Main Wizard.
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TemplateWizard;
using System.Windows.Forms;
using EnvDTE;

namespace CustomWizard
    public class NewWidgetTemplateWizard : IWizard
        private UserInputForm _inputForm;
        private string _projectName;
        private int _portNumber;
        private string _releaseSchema;
        private Guid _projectGuid;
        #region Implementation of IWizard

        public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)

                    _inputForm = new UserInputForm();
                    _projectName = _inputForm.ProjectName;
                    _portNumber = _inputForm.PortNumber;
                    _releaseSchema = _inputForm.ReleaseSchema;
                    _projectGuid = Guid.NewGuid();

                        _projectName );

            catch (Exception ex)

        private void SetUpChild()
            NewWidgetTemplateWizardChild.PortNumber = this._portNumber;
            NewWidgetTemplateWizardChild.ProjectName = this._projectName;
            NewWidgetTemplateWizardChild.ReleaseSchema = this._releaseSchema;
            NewWidgetTemplateWizardChild.ProjectGuid = this._projectGuid;
Supper simple solution..

Categories: Visual studio 10/up | VS 2005 | VS 2008

<VSTemplate Version="2.0.0" Type="ProjectGroup"
        <Name>New Widget Templates</Name>
        <Description> inlucde new widget template and widgetTests template</Description>
            <ProjectTemplateLink ProjectName="Widgets.$safeprojectname$">
            <ProjectTemplateLink ProjectName="Widgets.$safeprojectname$.Tests">
    <Assembly>CustomWizard, Version=, Culture=Neutral, PublicKeyToken=fbf8d46e0d2fda8f</Assembly>


Categories: Visual studio 10/up | VS 2005