Translate

Thursday 15 November 2012

Java Script Function

1. how to display block or none for control in javascript

<tr id="trBrowse" runat="server" style="display: none;">
      <td></td>
</tr>

trBrowse.Style.Add("display", "block");

How to get open folders list using C#?


To Open a particular folder in Explorer, just:
System.Diagnostics.Process.Start(@"explorer.exe", @"C:\Windows");
In fact, as Explorer is the asscoaited handler for folder, that could be written as:
System.Diagnostics.Process.Start(@"C:\Windows");
or
 string path="D:\\Test";
 System.Diagnostics.Process.Start("explorer.exe", path);


CheckForDuplicates confirmation message

protected void SaveButton_Click(object sender, EventArgs e)
{
    try
    {
        if (CheckForDuplicates())
        {
            //proceed normally
        }
    }
}

private bool CheckForDuplicates()
{
    //check database

            if (/*there are duplicates*/)
            {
                string message = "A duplicate name exists. Would you like to continue?";
                string scriptString = "<script language='javascript' 
                    type='text/javascript'>" + "return confirm('" + message + "');</script>";

                ScriptManager.RegisterStartupScript(this, this.GetType(), 
                    "script", scriptString, false);

                //here i would like to return their confirmation
            }
        }
    }
    return true;
}

Find Extented Ascii Value using javascript


<script type="text/javascript">
function CheckAll() {
var Titleid = document.getElementById('ID');
            var tit = Titleid.value;
            var T = [];
            for (var i = 0, j = Titleid.value.length; j--; i++) {
                T[i] = tit.charCodeAt(i);
                if (T[i] > 128) {
                    alert("Ascii found: " + String.fromCharCode(T[i]));
                    document.getElementById('ID').focus();
                    return false;
                }
            }

  return true;
        }
 </script>