<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(document).ready(function () { alert("Testing") $("#SponsorID").focusout(function () { var sponsor = $('#SponsorID').val(); var sponsorname = $('#Text1').val(); //alert(sponsor); $.ajax({ type: "POST", url: "HTMLControl.aspx/GetSponsorName", data: "{'username':'" + sponsor + "'}", contentType: "application/json; charset=utf-8", Method: "POST", dataType: "json", success: function (response) { var names = response.d; //alert(names); $('#Text1').val(names); }, failure: function (response) { alert("Not Valid"); } }); }); }); </script> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <div> SponsorID : <input id="SponsorID" type="text" required="required" runat="server"/> <input id="Text1" type="text"/> <br /><br /> Email : <input id="Email" type="email" required="required" runat="server"/> <br /><br /> Mobile Number : <input type="text" id="MobileNumber" name="Mobile" pattern="[789][0-9]{9}" maxlength="10" minlength='10' required="required" runat="server"/> <br /><br /> <asp:Button ID="Save" runat="server" Text="Save" /> </div> Imports System.Web.Services Imports System.Web.Script.Serialization Imports System.Data Imports System.Data.SqlClient Partial Class _Default Inherits System.Web.UI.Page <webmethod> _ Public Shared Function GetSponsorName(ByVal username As String) As String Dim msg As String = username Dim cn As New SqlConnection Dim comm As New SqlCommand Dim sqltrans As SqlTransaction Dim connectStr As String If cn.State = ConnectionState.Closed Then connectStr = ConfigurationManager.ConnectionStrings("connectstr").ToString() cn.ConnectionString = connectStr End If Dim Da As New SqlDataAdapter Dim Ds As New DataSet comm.CommandText = "select Membername from Registration where MemberiD = '" & username & "'" comm.CommandTimeout = 0 comm.Connection = cn comm.Transaction = Nothing Da.SelectCommand = comm Da.Fill(Ds) comm.Connection = cn If Ds.Tables(0).Rows.Count > 0 Then msg = Ds.Tables(0).Rows(0)(0).ToString() Else msg = "Sponsor ID Not Valid" End If Return msg End Function End Class</webmethod>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)