Welcome Guest ( Log In | Register )

Bump Topic Topic Closed RSS Feed

Outline · [ Standard ] · Linear+

.NET Fire custom validator onblur() in textbox, VB.NET

views
     
TSsteven1379
post Aug 26 2011, 04:02 PM, updated 15y ago

Getting Started
**
Junior Member
234 posts

Joined: Nov 2006
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
post Aug 26 2011, 04:37 PM

6 STARS
******
Senior Member
1,684 posts

Joined: Apr 2008


use javascript
jonchai
post Aug 26 2011, 05:06 PM

Ask me anything
******
Senior Member
1,568 posts

Joined: Sep 2010


Use ontextchanged event.
TSsteven1379
post Aug 26 2011, 05:47 PM

Getting Started
**
Junior Member
234 posts

Joined: Nov 2006
QUOTE(jonchai @ Aug 26 2011, 05:06 PM)
Use ontextchanged event.
*
beside this method ? is there any way to fire the custom validator ?
eueu
post Aug 27 2011, 11:34 AM

Enthusiast
*****
Senior Member
766 posts

Joined: Jan 2003
Can only give you hints, lazy to write the solutions smile.gif

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 rclxm9.gif

This post has been edited by eueu: Aug 27 2011, 11:37 AM
TSsteven1379
post Aug 28 2011, 06:58 PM

Getting Started
**
Junior Member
234 posts

Joined: Nov 2006
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
post Aug 29 2011, 10:01 AM

Enthusiast
*****
Senior Member
766 posts

Joined: Jan 2003
Try to use document.getElementById instead of $get("")

If still cant, read this article.
http://brian.dobberteen.com/code/jquery_aj...stom_validator/


TSsteven1379
post Aug 29 2011, 03:34 PM

Getting Started
**
Junior Member
234 posts

Joined: Nov 2006
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

Topic ClosedOptions
 

Change to:
| Lo-Fi Version
0.0139sec    0.63    5 queries    GZIP Disabled
Time is now: 13th December 2025 - 11:49 PM