Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No keypress event for asp textbox

Tags:

c#

asp.net

Hello i need to work on keypress event of asp textbox but keypress event not available for the asp textbox. Is there alternative available for this problem? Plz help!

like image 586
jitendra Avatar asked Feb 24 '23 08:02

jitendra


1 Answers

Make use of keypress event of javascript + textbox

and call the serverside function by using ajax or using pagemthods.

.cs file
[ScriptMethod, WebMethod]

   public static string docall()
   {
      return "Hello";
   }

.aspx file

<script type="text/javascript">
      function btnAccept_onclic() {
          PageMethods.docall(onSuccess, onFailure);
      }

  function onSuccess(result) {
          alert(result);
      }


      function onFailure(error) {
          alert(error);
      } 

</script>

check this : http://blogs.microsoft.co.il/blogs/gilf/archive/2008/10/04/asp-net-ajax-pagemethods.aspx

like image 86
Pranay Rana Avatar answered Mar 12 '23 00:03

Pranay Rana