Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET C#4.0 jQuery
hi all
i need to call the code behind the function on blur event the mobilevalidate function is called and working fine.but i need to call the code behind function CheckDateTime. pls help me
 
<script type="text/javascript">
      function mobilevalidate() {
          if (document.getElementById('<%= txtcallerid.ClientID%>').value != "") {
 

          if (document.getElementById('<%= txtcallerid.ClientID%>').value.match(/^\d+$/))
//i need to call the code behind function <pre lang="xml">CheckDateTime
                  return true;
              else
                  alert(&quot;Please Enter Valid Caller Id&quot;);
              document.getElementById(&#39;&lt;%= txtcallerid.ClientID%&gt;&#39;).value = &quot;&quot;;
              document.getElementById(&#39;&lt;%= txtcallerid.ClientID%&gt;&#39;).focus();
          }
          alert(&quot;Please Enter Caller Id&quot;);
          return false;
 
      }
 
my.cs file
[System.Web.Services.WebMethod]
  public static string CheckDateTime(string args)
  {
      ddlload();
  }
Posted 28-Mar-13 7:23am
Edited 28-Mar-13 7:39am
Maciej Los158.3K
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

First you need to take reference of ScriptManager control from your page.
<asp:scriptmanager id="scriptmanager" runat="server"></asp:scriptmanager>
If it is already there to your masterpage then no need. Then from your mobilevalidate method you can call server side method CheckDateTime like as follows
PageMethods.CheckDateTime("yourargument");
 
You can also called that serverside method using jquery or other client side library like prototype. If you search online then you will find many codesample.
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 277
1 Maciej Los 220
2 DamithSL 190
3 Raul Iloc 185
4 Richard MacCutchan 175
0 OriginalGriff 5,130
1 DamithSL 4,197
2 Maciej Los 3,670
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,821


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 28 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100