I have email field and label
<asp:TableRow runat="server">
<asp:TableCell runat="server">
<asp:TextBox runat="server" ID="txtUserEmail" onfocusout="emailVerification()" CssClass="forTextbox ui-corner-all" PlaceHolder="Enter your email"></asp:TextBox>
</asp:TableCell>
<asp:TableCell runat="server">
<asp:ScriptManager runat="server" ID="smForEmail"></asp:ScriptManager>
<asp:UpdatePanel runat="server" ID="upLblEmail">
<ContentTemplate>
<asp:Label runat="server" ID="lblEmail"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</asp:TableCell>
</asp:TableRow>
And some other fields as well.
I want when user move to next field onfocusout="emailVerification()" method is called. In this method I want to check either email is exists in database or not. For this I write stored procedure.
USE [CDistributors]
GO
/****** Object: StoredProcedure [dbo].[sp_InsertUser] Script Date: 2/17/2016 2:50:05 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[sp_InsertUser]
(@Email varchar(50) = null,
@ReturnValue int = null)
As
Begin
SET NOCOUNT ON;
IF EXISTS (SELECT UserId from Users where Email = @Email)
Begin
return 0; -- Email already registered
End
Else
Begin
return 1; -- Email is not registered yet
End
End
And JavaScript function is
// code for email verification
$(function () {
function emailVerification() {
// What code to call stored procedure that return integer
}
});
Please help.