Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
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

XML
<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
C#
[System.Web.Services.WebMethod]
  public static string CheckDateTime(string args)
  {
      ddlload();
  }
Posted
Updated 28-Mar-13 6:39am
v2

1 solution

First you need to take reference of ScriptManager control from your page.
ASP.NET
<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
C#
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.
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900