Jun 28, 2007

encrypt configuration file

aspnet_regiis -pe "appSettings" -app "/gbsa" -prov "DataProtectionConfigurationProvider"

aspnet_regiis -pe "appSettings" -app "/gbsa" -prov "Rsa ProtectedConfigurationProvider"

            

Jun 27, 2007

Data View Part

Form web Part can connect datavew web part. Here are the rules.

If dataview web part define a filter using input parameter, form web part connect dataview webpart to modify view using parameters from.

If dataview web part does not define a filter, form web part connect dataview webpart to filter view using data values from.

            

submit only once

            
            

select all text when focus in a text box

            FormUtil.setTextboxes = function() {
            var colInputs = document.getElementsByTagName("input");
            var colTextAreas = document.getElementsByTagName("textarea");

            for (var i=0; i < colInputs.length; i++){
            if (colInputs[i].type == "text"  colInputs [i].type == "password") {
            colInputs[i].onfocus = function () { this.select(); };
            }
            }

            for (var i=0; i < colTextAreas.length; i++){
            colTextAreas[i].onfocus = function () { this.select(); };
            }
            };
            

maxlength for text box

            

            TextUtil.isNotMax = function(oTextArea) {return oTextArea.value.length != oTextArea.getAttribute(“maxlength”);}

            var TextUtil = new Object();
            

set textbox's next button click

            string script = @"
            function clickButton(e, buttonid)
            {
            var bt = document.getElementById(buttonid);
            if (typeof bt == 'object')
            {
            if (navigator.appName.indexOf('Microsoft Internet Explorer')>(-1)){
            if (event.keyCode == 13){
            bt.click();
            return false;
            }
            }
            else
            {
            if (e.keyCode == 13)
            {
            bt.click();
            return false;
            }
            }
            }
            } ";
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "search", script, true);
            if (this.Request["tab"] == null || this.Request["tab"] == "All Resources")
            {
            this.txtGeneralSearch.Attributes.Add("onkeypress", "return clickButton(event,'" + this.btnSearch.ClientID + "')");
            }
            

clean up the white-space text

            document.documentElement.firstChild.nextSibling.firstChild;
            
Sometime the above works in IE, but not work in FireFox, because IE ignore the whitespace text, but fireFox does not to solve this problem you need to call this function, before access it.

            function cleanWhitespace( element ) {
            element = element || document;
            var cur = element.firstChild;
            while ( cur != null )
            {
            if ( cur.nodeType == 3 && ! /\S/.test(cur.nodeValue) )
            {
            temp = cur;
            cur = cur.nextSibling;
            temp.parentNode.removeChild(temp);
            }
            else
            {
            if ( cur.nodeType == 1 )
            {
            cleanWhitespace( cur );
            }
            cur = cur.nextSibling;
            }
            }
            }
            

digital tv standard

ATSC (Advanced Television System Committee) used in North America, Japan, Korea, Taiwan, and parts of Latin America DVB-T (Digital Video Broadcasting - Terrestrial) used in Europe ISDB-T (Integrated Services Digital Broadcasting - Terrestrial) used in Japan

Jun 20, 2007

delegate asyn call

class Program
{
            static void Main()
            {
            AsyncCallback callback = new AsyncCallback(Callback);
            Func f = Console.ReadLine;
            f.BeginInvoke(Callback, null);
            Thread.Sleep(Timeout.Infinite);
            }

            static void Callback(IAsyncResult result)
            {
            AsyncResult async = result as AsyncResult;
            Func f = async.AsyncDelegate as Func;
            string s = f.EndInvoke(result);
            Console.WriteLine(s);
            Environment.Exit(0);
            }
}