Outline ·
[ Standard ] ·
Linear+
.NET Fire custom validator onblur() in textbox, VB.NET
|
TSsteven1379
|
Aug 26 2011, 04:02 PM, updated 15y ago
|
Getting Started

|
hi all....
i want whenever a txtEmail lost focus ... it will call server side event eg: CheckEmailExists instead of waiting a [submit] button hitted to fire the checking.
Anyone can help ? please dont ask me to client side validation as i need to query database to get result.
|
|
|
|
|
|
gerrardling
|
Aug 26 2011, 04:37 PM
|
|
use javascript
|
|
|
|
|
|
jonchai
|
Aug 26 2011, 05:06 PM
|
|
Use ontextchanged event.
|
|
|
|
|
|
TSsteven1379
|
Aug 26 2011, 05:47 PM
|
Getting Started

|
QUOTE(jonchai @ Aug 26 2011, 05:06 PM) beside this method ? is there any way to fire the custom validator ?
|
|
|
|
|
|
eueu
|
Aug 27 2011, 11:34 AM
|
|
Can only give you hints, lazy to write the solutions  if for Javascript, u can use JSON. or u can use WebServices (asmx will be enuf) or more tricky way: 1) add updatepanel to ur page 2) add a hidden button (btnCheckEmail) which to postback to server for CheckEmailExists() function 3) bind a jscript to ur txtEmail to call __doPostBack('btnCheckEmail_ClientId','') 4) bingo~ happy coding This post has been edited by eueu: Aug 27 2011, 11:37 AM
|
|
|
|
|
|
TSsteven1379
|
Aug 28 2011, 06:58 PM
|
Getting Started

|
eueu ... thanks for reply... but something i dont understand over here ...
<asp:CustomValidator ID="CustomValidator1" runat="server" Display="Dynamic" ControlToValidate="txtLoginId" ErrorMessage="Login ID exists" ClientValidationFunction="CHECK"></asp:CustomValidator>
function CHECK(source, args) { //alert($get('<%= txtLoginId.ClientID %>').value); PageMethods.GetContactName($get('<%= txtLoginId.ClientID %>').value, onSucceeded, onFailed); } function onSucceeded(msg, userContext, methodName, onFailed) { var gg = msg; if (gg != 1) {
args.IsValid = false; } } function onFailed(error, userContext, methodName) { alert("An error occurred"); }
vb.net code Public Shared Function GetContactName(ByVal s As String) As Integer Return Convert.ToInt16(s) End Function
the problem is args.isValid can only be used inside CHECK function... because it receive args parameter from the custom validator...
i want to fire the args.IsValid in onSucceeded ...
|
|
|
|
|
|
eueu
|
Aug 29 2011, 10:01 AM
|
|
Try to use document.getElementById instead of $get("") If still cant, read this article. http://brian.dobberteen.com/code/jquery_aj...stom_validator/
|
|
|
|
|
|
TSsteven1379
|
Aug 29 2011, 03:34 PM
|
Getting Started

|
brother, too hard for me to understand this ... i couldnt even get compiled successfully Added on August 29, 2011, 7:05 pmbrother i am trying to use the web service method ... CODE function CHECK(source, args) { //alert($get('<%= txtLoginId.ClientID %>').value); //PageMethods.GetContactName($get('<%= txtLoginId.ClientID %>').value, onSucceeded, onFailed); dummyWebservice.HelloWorld(); } but it give me dummyWebservice undefined when onblur on textbox ... This post has been edited by steven1379: Aug 29 2011, 07:05 PM
|
|
|
|
|