Thursday, October 29, 2009

Name of the Javascript Tools

jQuery
Moo Tools
YUI
Prototype
Scriptaculous
ExtJS
Dojo
MochiKit


these are all the website names where we can find the latest javascript tools/functions

Validate File Upload type while Uploading

var fileTypes=["txt","doc","ppt","pdf","xls"];
function preview(what){
var source=what.value;
var ext=source.substring(source.lastIndexOf(".")+1,source.length).toLowerCase();
for (var i=0; i < fileTypes.length; i++) if (fileTypes[i]==ext) break;

if (i < fileTypes.length){}
else
{
alert("Please upload a file with an extention of one of the following:\n\n"+fileTypes.join(", "));
}

}


<input type="file" id="file" name="file" onchange="preview(this)" />

Alfanumeric IE and Firefox Keypress Event Handler

function AlfaNumeric(e)
{
var key;
var keychar;

if (window.event)
{key = window.event.keyCode;}
else if (e)
{key = e.which;}
else
{return true;}

keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();

// control keys
if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27))
{return true;}
else if (("abcdefghijklmnopqrstuvwxyz0123456789").indexOf(keychar) > -1)
{return true;}
else
{return false;}
}



<input type="text" id="txtAlphabetsa" onkeypress="return AlfaNumeric(event);" name="Phone" />

Monday, September 1, 2008

Performance Tips for Binding Grid in Vs.Net 2005

When using SqlDataSource, ObjectDataSource etc., an important point to note is that, you dont need to bind the Data explicitly to the controls using DataBind.Ex.-

GridView1.DataSourceId = SqlDataSource1 // where SqlDataSource1 is the ID of the Datasource control.

That is all required. You dont require the GridView1.DataBind(); method which we are very familiar from .NET 1.0. The reason is that, the DataBind method is implicitly called by the EnsureDataBound method of the DataSource control. If we call it explicitly, then it results in a double binding of Data.

-Ramya Jasti

Wednesday, October 10, 2007

JavaScript Go Back Function

function goBack()
{
window.history.go(-1);
return false;
}


<a href='#' style='text-decoration: none;'><img
src='images/but-cancel.gif' onclick='goBack();' border='0' alt='Cancel' /></a>

Friday, September 28, 2007

JavaScript Advanced URL Validation

function URLValidate()
{
var urlRegxp = /^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([\w]+)(.[\w]+){1,2}$/;

var a = document.getElementById("<%=txtAcctNo.ClientID%>").value.replace(/^\s+|\s+$/g,"");
if(urlRegxp.test(a) != true)
{
document.getElementById("<%=lblPPSConnectionUrl.ClientID%>").innerHTML = "";
document.getElementById("<%=lblErrPPSConnectionUrl.ClientID%>").innerHTML = "[ URL is in incorrect format ]";
document.getElementById("trPPSConnectionUrl").style.display = "block";
document.getElementById("<%=txtPPSConnectionUrl.ClientID%>").focus();
rtnFlag = 0;
}

}

Saturday, September 1, 2007

JavaScript URL Validation

function ValideEmail() //working well
{
var theurl = document.form1.TextBox1.value;
var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/
if (tomatch.test(theurl))
{
window.alert("URL OK.");
return true;
}
else
{
window.alert("URL invalid. Try again.");
return false;
}
}