Nitin Dhiman. Powered by Blogger.

javascript to change group name

No comments
change group name :
<script language="javascript" type="text/javascript">
function changeValidationGrop(){
var btn = document.getElementById("<%=Button1.ClientID %>");
//rfvUsername = document.getElementById("<% = rfvUsername.ClientID %>");
//rfvUsername.ValidationGroup = "Demo";
//alert(rfvUsername.ValidationGroup);
btn.onclick = function(){
WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("Button1", "", true, "Customer", "", false, false));
}
}
<script>

get youtube video's publish date, view count, title and other data

No comments

    private void BindVideo(string videoId)
    {
        string sTitle = string.Empty;
        bool bPublished = false;
        bool bTitle = false;
        try
        {
            XmlTextReader reader = new XmlTextReader("http://gdata.youtube.com/feed/api/videos/" + videoId);
            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        {
                            switch (reader.Name)
                            {
                                case "published":
                                    bPublished = true;
                                    break;
                                case "yt:statistics":
                                    {
                                        while (reader.MoveToNextAttribute())
                                        {
                                            if (reader.Name.ToLower().Equals("viewcount"))
                                                sViewCount = reader.Value;
                                        }
                                    }
                                    break;
                                case "media:title":
                                    bTitle = true;
                                    break;
                            }
                            break;
                        }
                    case XmlNodeType.Text:
                        if (bPublished)
                        {
                            dtPublishDate = Convert.ToDateTime(reader.Value);
                        }
                        else if (bTitle)
                        {
                            sTitle = reader.Value;
                        }
                        break;
                    case XmlNodeType.EndElement:
                        {
                            bPublished = false;
                            bTitle = false;
                            break;
                        }
                }
            }
            reader.Close();
            Response.Write("Published on: " + dtPublishDate.ToLongDateString() + "");
            Response.Write("View Count: " + sViewCount + "");
            Response.Write("Title: " + sTitle + "");
        }
        catch { }
    }

PNG Fix

No comments

<!--[if lt IE 7]>

<script language="JavaScript">

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.

{

   var arVersion = navigator.appVersion.split("MSIE")

   var version = parseFloat(arVersion[1])

   if ((version >= 5.5) && (document.body.filters))

   {

      for(var i=0; i<document.images.length; i++)

      {

         var img = document.images[i]

         var imgName = img.src.toUpperCase()

         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")

         {

            var imgID = (img.id) ? "id='" + img.id + "' " : ""

            var imgClass = (img.className) ? "class='" + img.className + "' " : ""

            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "

            var imgStyle = "display:inline-block;" + img.style.cssText

            if (img.align == "left") imgStyle = "float:left;" + imgStyle

            if (img.align == "right") imgStyle = "float:right;" + imgStyle

            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle

            var strNewHTML = "<span " + imgID + imgClass + imgTitle

            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"

            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"

            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"

            img.outerHTML = strNewHTML

            i = i-1

         }

      }

   }   

}

window.attachEvent("onload", correctPNG);

</script>

<![endif]-->

Javascript to get querystring

No comments
function to fetch querysting values:

function getQuerystring(key, default_)
{
if (default_==null) default_="";
key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
var qs = regex.exec(window.location.href);
if(qs == null)
return default_;
else
return qs[1];
}


to get the value of parameter:

var author_value = getQuerystring('parameter_Name');

Bravenet Links

No comments
Following are the bravenet links containing some JQuery code:

1) http://nitindhiman.bravehost.com/TableChart.htm

2) http://nitindhiman.bravehost.com/dropdown.htm

3) http://nitindhiman.bravehost.com/puzzle.htm

4) http://nitindhiman.bravehost.com/TooltipBubble.htm

5) http://nitindhiman.bravehost.com/horizontalAccordion.htm

6)

To get the names of the latest altered storedprocedures in SQL.

No comments
following is the query:
declare @date1 datetime
set @date1 = '1-sep-2008'

select specific_name,last_altered,created from information_schema.routines
where datediff(day,@date1, last_altered) > 0
or
datediff(day,@date1, created) > 0

Textbox validation for numeric and other key codes.

No comments
function fncInputNumericValuesOnly()
{
if(!(event.keyCode==45||event.keyCode==46||event.keyCode==48||event.keyCode==49||event.keyCode==50||event.keyCode==51||event.keyCode==52||event.keyCode==53||event.keyCode==54||event.keyCode==55||event.keyCode==56||event.keyCode==57))
{
event.returnValue=false;
}
}

< asp:TextBox id="txtQty" runat="server" onkeypress= "fncInputNumericValuesOnly('')"/>

Or add any other ascii code as keyCode to allow like:

8=backspace
190=dot
37=left arrow
39=right arrow
16=shift