Mobile Content

Wednesday, March 7, 2012

On Keypress show character at load event in

Without taking any control, this Example will show how we can print the character on webpage when any key is pressed on keyboard
Here we will use javascript.
in .aspx page

<script type="text/javascript">
    document.onkeyup = KeyCheck;
    function KeyCheck(e)
        var KeyID = (window.event) ? event.keyCode : e.keyCode;
                __doPostBack('__Page', KeyID);
//here ascii value of character will get when key is pressed

in .vb page
 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Page.ClientScript.GetPostBackEventReference(Me, "")
 Dim eventArgs As String = Request("__EVENTARGUMENT")
   If eventArgs <> "" Then

End Sub
//here we will get keycode of character and get converted into character using Chrw keyword

in .cs

protected void Page_Load(object sender, System.EventArgs e)
Page.ClientScript.GetPostBackEventReference(this, "");
string eventArgs = Request("__EVENTARGUMENT");
if (!string.IsNullOrEmpty(eventArgs))