Some important technique in JavaScript


##Some simple JavaScript Technique

##Open Popup with sending a URl get value:

function ItemDetails(pName,id)
{ alert(id);
window.open(pName + "?ID=" + id,"MyWindow","status = 1,height = 400,width = 550,resizable = 1,toolbar=1'")
}

//Open JS Popup from code behind

string str="";
str = str + "window.open('PrintMap.aspx?id=" + id + "','PrintMe','height=520px,width=620px,scrollbars=1,resizable=yes,toolbar=yes')";

str = str + "";
ClientScript.RegisterStartupScript(this.GetType(), "onclick", str);


// below technique is not recommended

string tem;
tem = "Page2.aspx";
Response.Write("script window.open('" + tem + "','_blank','scrollbars=yes,width=400,height=500,resizable=yes') script");

##Page redirection using JS:

//redirect to current page(Not reload)
window.location=location.href;

##Close Popup and reflect chage to parrent page

function closePopup()
{
//window.opener.document.location.reload();
/* OR window.opener.document.location.href='myParentWindow.newpage'; */
//self.close ()
window.opener.document.forms(0).submit();
window.close();
}

##Check is not number value in javascript

function CheckAge(source, arguments)
{ var myVal=arguments.Value;
//alert(myVal);
if(isNaN(myVal) || myVal<19)
{
arguments.IsValid=false;
}
else
arguments.IsValid=true;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s