Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts

October 9, 2010

jQuery intellisense in Visual Studio 2008


To enable intellisense completion for jQuery within VS you'll want to follow three steps:
Step 1: Install VS 2008 SP1
VS 2008 SP1 adds richer JavaScript intellisense support to Visual Studio, and adds code completion support for a broad range of JavaScript libraries.
You can download VS 2008 SP1 and Visual Web Developer 2008 Express SP1 here.
Step 2: Install VS 2008 Patch KB958502 to Support "-vsdoc.js" Intellisense Files
Two weeks ago we shipped a patch that you can apply to VS 2008 SP1 and VWD 2008 Express SP1 that causes Visual Studio to check for the presence of an optional "-vsdoc.js" file when a JavaScript library is referenced, and if present to use this to drive the JavaScript intellisense engine.
These annotated "-vsdoc.js" files can include XML comments that provide help documentation for JavaScript methods, as well as additional code intellisense hints for dynamic JavaScript signatures that cannot automatically be inferred.  You can learn more about this patch here.  You can download it for free here.
Step 3: Download the jQuery-vsdoc.js file
We've worked with the jQuery team to put together a jQuery-vsdoc.js file that provides help comments and support for JavaScript intellisense on chained jQuery selector methods.  You can download both jQuery and the jQuery-vsdoc file from the official download page on the jQuery.com site:
step1 Save the jquery-vsdoc.js file next to your jquery.js file in your project (and make sure its naming prefix matches the jquery file name):step2 You can then reference the standard jquery file with an html <script/> element like so:step3
Or alternatively reference it using the <asp:scriptmanager/> control, or by adding a /// <reference/> comment at the top of a standalone .js file.
When you do this VS will now look for a -vsdoc.js file in the same directory as the script file you are referencing, and if found will use it for help and intellisense.  The annotated
For example, we could use jQuery to make a JSON based get request, and get intellisense for the method (hanging off of $.):
step4 step5 step6 step7

July 19, 2010

Javascript Char Codes (Key Codes)


Event Key Codes
Javascript events are used to capture user keystrokes. Just type a character into the 
Textbox below to Check the key code.


KeyPress Javascript Key Code

Below is a table of key codes for the keys on a multimedia keyboard.


Key Pressed Javascript Key Code Key Pressed Javascript Key Code
backspace 8 x 88
tab 9 y 89
enter 13 z 90
shift 16 left window key 91
ctrl 17 right window key 92
alt 18 select key 93
pause/break 19 numpad 0 96
caps lock 20 numpad 1 97
escape 27 numpad 2 98
page up 33 numpad 3 99
page down 34 numpad 4 100
end 35 numpad 5 101
home 36 numpad 6 102
left arrow 37 numpad 7 103
up arrow 38 numpad 8 104
right arrow 39 numpad 9 105
down arrow 40 multiply 106
insert 45 add 107
delete 46 subtract 109
0 48 decimal point 110
1 49 divide 111
2 50 f1 112
3 51 f2 113
4 52 f3 114
5 53 f4 115
6 54 f5 116
7 55 f6 117
8 56 f7 118
9 57 f8 119
a 65 f9 120
b 66 f10 121
c 67 f11 122
d 68 f12 123
e 69 num lock 144
f 70 scroll lock 145
g 71 semi-colon 186
h 72 equal sign 187
i 73 comma 188
j 74 dash 189
k 75 period 190
l 76 forward slash 191
m 77 grave accent 192
n 78 open bracket 219
o 79 back slash 220
p 80 close braket 221
q 81 single quote 222
r 82
s 83
t 84
u 85
v 86
w 87

May 1, 2010

Java Script Alert for ASP.net 2.0





Hi All,
I come across people were asking about, how to display alert messagebox after callback.
Im not sure this have been posted before or not, but i thought this is good to be share.
Below is the example:
C#

protected void Button1_Click(object sender, EventArgs e)
{
// Alert with messagebox after callback
// Your process here e.g. add/edit/delete from database and etc
// Assume your process take 5 second to complete
System.Threading.Thread.Sleep(5000);
// Build your alert script
StringBuilder sbScript = new StringBuilder();
sbScript.Append("");
// Make use ScriptManager to register the script
ScriptManager.RegisterStartupScript(this, this.GetType(), "@@@@MyCallBackAlertScript", sbScript.ToString(), false);
}
VB

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
' Alert with messagebox after callback
' Your process here e.g. add/edit/delete from database and etc
' Assume your process take 5 second to complete
System.Threading.Thread.Sleep(5000)

' Build your alert script
Dim sbScript As New StringBuilder()
sbScript.Append("")

' Make use ScriptManager to register the script
ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "@@@@MyCallBackAlertScript", sbScript.ToString(), False)
End Sub