28 Nov 2011

 [How to] 如何卸载Xcode

 

 $ sudo /Developer/Library/uninstall-devtools --mode=all

 

09 Nov 2011

AutoGenerateColumns='true'的GridView如何支持htmlencode/htmldecode

我们知道BoundField.HtmlEncode 属性可以设置一个单元格是否能够htmlencode,我今天碰到的问题是:自动生成列的GridView,表头可能是包含html的比如<font color=red>邮件</font>,默认被htmlencode了,而我不希望这样做,所以有了如下的代码:

 

/// <summary>
/// Handles the PreRender event of the gvSource control.
/// </summary>
/// <param name=“sender”>The source of the event.</param>
/// <param name=“e”>The <see cref=“System.EventArgs”/> instance containing the event data.</param>
protected void gvSource_PreRender( object sender , EventArgs e )
{
    GridView gridView = sender as GridView;
    if ( gridView != null && gridView.HeaderRow != null && gridView.HeaderRow.Cells != null )
    {
        for ( int j = 0 ; j < gridView.HeaderRow.Cells.Count ; j++ )
        {
            gridView.HeaderRow.Cells[j].Text = System.Web.HttpUtility.HtmlDecode( gridView.HeaderRow.Cells[j].Text );
        }
    }
}

09 Nov 2011

AutoGenerateColumns='true'的GridView如何支持htmlencode/htmldecode

我们知道BoundField.HtmlEncode 属性可以设置一个单元格是否能够htmlencode,我今天碰到的问题是:自动生成列的GridView,表头可能是包含html的比如<font color=red>邮件</font>,默认被htmlencode了,而我不希望这样做,所以有了如下的代码:

 

/// <summary>
/// Handles the PreRender event of the gvSource control.
/// </summary>
/// <param name=“sender”>The source of the event.</param>
/// <param name=“e”>The <see cref=“System.EventArgs”/> instance containing the event data.</param>
protected void gvSource_PreRender( object sender , EventArgs e )
{
    GridView gridView = sender as GridView;
    if ( gridView != null && gridView.HeaderRow != null && gridView.HeaderRow.Cells != null )
    {
        for ( int j = 0 ; j < gridView.HeaderRow.Cells.Count ; j++ )
        {
            gridView.HeaderRow.Cells[j].Text = System.Web.HttpUtility.HtmlDecode( gridView.HeaderRow.Cells[j].Text );
        }
    }
}

22 Jun 2011

在Console下输入密码,以星号代替。

如何在Console下输入密码,像*unix系统下那样不显示,或者显示星号,如下代码经过测试:

/// <summary>
/// Gets the console secure password.
/// </summary>
/// <returns></returns>
private static SecureString GetConsoleSecurePassword( )
{
    SecureString pwd = new SecureString( );
    while ( true )
    {
        ConsoleKeyInfo i = Console.ReadKey( true );
        if ( i.Key == ConsoleKey.Enter )
        {
            break;
        }
        else if ( i.Key == ConsoleKey.Backspace )
        {
            pwd.RemoveAt( pwd.Length - 1 );
            Console.Write( "\b \b" );
        }
        else
        {
            pwd.AppendChar( i.KeyChar );
            Console.Write( "*" );
        }
    }
    return pwd;
}

/// <summary>
/// Gets the console password.
/// </summary>
/// <returns></returns>
private static string GetConsolePassword( )
{
    StringBuilder sb = new StringBuilder( );
    while ( true )
    {
        ConsoleKeyInfo cki = Console.ReadKey( true );
        if ( cki.Key == ConsoleKey.Enter )
        {
            Console.WriteLine( );
            break;
        }

        if ( cki.Key == ConsoleKey.Backspace )
        {
            if ( sb.Length > 0 )
            {
                Console.Write( "\b\0\b" );
                sb.Length--;
            }

            continue;
        }

        Console.Write( '*' );
        sb.Append( cki.KeyChar );
    }

    return sb.ToString( );
}

gist:https://gist.github.com/1039424

03 Mar 2010

请珍爱自己的身体

see see:

http://www.cnblogs.com/yiway/archive/2010/02/23/1672173.html

21 Jan 2010

使用window.location跳转,在IE中UrlReffer不被记录

使用window.location跳转,在FF中,没问题,下一页面可以取得UrlReffer,但在IE中UrlReffer不被记录

真变态,

让我头痛了半天,弄了个丑陋的办法做了如下实现:

function safeRedirectToCart(url) {
    var isIE = jQuery.browser.msie;
    if (!isIE) {
        window.location = url;
        return;
    }
    $(".btnCart").get(0).click();
}

说明:在页面上render一个连接(可以用样式表控制不显示),判断如果是IE浏览器然则调用其click,嘿嘿,就这个。

21 Jan 2010

使用window.location跳转,在IE中UrlReffer不被记录

使用window.location跳转,在FF中,没问题,下一页面可以取得UrlReffer,但在IE中UrlReffer不被记录

真变态,

让我头痛了半天,弄了个丑陋的办法做了如下实现:

function safeRedirectToCart(url) {
    var isIE = jQuery.browser.msie;
    if (!isIE) {
        window.location = url;
        return;
    }
    $(".btnCart").get(0).click();
}

说明:在页面上render一个连接(可以用样式表控制不显示),判断如果是IE浏览器然则调用其click,嘿嘿,就这个。

18 Dec 2009

Graffiti CMS 开源了

see also:http://weblogs.asp.net/kencox/archive/2009/12/17/graffiti-cms-is-now-free-open-source.aspx

18 Dec 2009

Graffiti CMS 开源了

see also:http://weblogs.asp.net/kencox/archive/2009/12/17/graffiti-cms-is-now-free-open-source.aspx

11 Dec 2009

Repeater,DataList等嵌套如何绑定父repeater字段?

嘿嘿,其实Container有个Parent属性,把它转换为RepeaterItem再取其DataItem

DataBinder.Eval(((System.W

eb.UI.WebControls.Repeat erItem)Container.Parent.Parent.Parent).DataItem