Click here to Skip to main content
15,921,884 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to all,

I have a Web Service to Check the User Name is Already Exists or Not.

I have called the Web Service In .cs(Code Behind) file like Following.
C#
txtUserName.Attributes.Add("onChange","return CheckUserNameAvailability()");

JavaScript
function CheckCommonMasterAvailability() {
//    debugger;
    masterCheck = document.getElementById('ctl00_cphMaster_hdnStatus');
    setTimeout("", 10000);
    if ((document.getElementById('ctl00_cphMaster_hdnValue').value == "") || (document.getElementById('ctl00_cphMaster_hdnValue').value.toUpperCase() != Trim(txtCommonName.value().toUpperCase()))) {
        if ((ddlReferenceCode.value() != "0") && (Trim(txtCommonName.value()) != "")) {
            masterValue = Trim(txtCommonName.value());
            SCMService.CheckMasterAvilability("COMMONMASTER", Trim(txtCommonName.value()), ddlReferenceCode.value(), "", "", "", OnMasterCheck);
            return false;
        }
    }
    else {
        masterCheck.value = "0";
    }
}






if Suppose the user enter the name and suddenly click the save button the onChange event wont perform Suddenly before the control is going to server, so it saved and then the onchange event called.

i check the status value that is return by webservice method. but the method called after control is going to server and then the onchange event is performed.

It Works Properly in IE but not in FireFox..
How can i solve this problem?

Is there any other way to do this?

Thanks to all
Posted

1 solution

Yes.

Delay the form submission by Button. You can use OnClientClick property of button to hook a Javascript method where you can delay the submission.

First the JS Click method is executed and then the server onClick. This will buy you some time to manipulate as per your need.
 
Share this answer
 
Comments
Dalek Dave 31-Aug-10 12:37pm    
Good call.

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