Thursday, September 21, 2006

Java Script tips

close window with javascript

Close Window






Create Date Time in javascript
var datetime = new Date();

JavaScript Intellisense

Changing this targetSchema property tells the Visual Studio .NET editor what browser I would like my Intellisense to be compatible with. When testing javascript code specific to Netscape I select the Netscape Navigator 4.0 option. Then for example, when I type the javascript keyword/object document followed by the usual dot (period), I get the Intellisense populated with all the Netscape Navigator 4.0 compliant properties and methods. The same is true when I select the Internet Explorer 5.0 option.


ref: http://blogs.crsw.com/mark/articles/648.aspx

ref: http://www.c-point.com/javascript_editor.php

Capture Mouse Position in JavaScript
var e = window.event;
var x = e.screenX;
var y = e.screenY;

JavaScript PostBack
onmousedown="javascript: <%#getPostBack()%>;"

protected string getPostBack()
{
return this.Page.GetPostBackEventReference(this, "@@@@@buttonPostBack"");
}

protected void Page_Load(object sender, System.EventArgs e)
{
// this Is a postback, then we care
if( this.IsPostBack )
{
// determine who caused the post back
string eventArg = Request[ "__EVENTARGUMENT" ];
// if null ( could it ever be null? )
if( eventArg != null )
{
// this post back can occur if we raise the event or if the Web Form itself raises the event.
// therefore, i always like to put something in the eventarg that lets me identify it as an event
// that i raised. i use @@@@@. but you can use whatever you like, just make sure it is unique.

// i also like to make the ClientId part of the value if i am posting back within a user control or
// custom control. including the ClientId in a user or custom control enables me to programmatically
// determine which instance of the control executed the postback. again we do this because all postbacks
// for all instances of all controls on the page are being funneled through this one method.
int offset = eventArg.IndexOf( "@@@@@" );
if( offset > -1 )
{
// this is an event that we raised. so do whatever you need to here.
}
}
}
}

ref: http://weblogs.asp.net/mnolton/archive/2003/06/04/8260.aspx

0 comments: