Validation Without Page Refresh .
-
Hi All, I would like to perform some validation on an entry into a text box in the TextChanged event without causing the entire page to refresh. In a Email-ID TextBox m checking whether that mailid is duplicate or not. I want to prevent user by entering duplicate mail-id. I used Update Panel, still it get refresh. any solution ??
-
Hi All, I would like to perform some validation on an entry into a text box in the TextChanged event without causing the entire page to refresh. In a Email-ID TextBox m checking whether that mailid is duplicate or not. I want to prevent user by entering duplicate mail-id. I used Update Panel, still it get refresh. any solution ??
why text change event ? Its means you are doing post back on every changed of textbox char. Do it on Submit button click. And Place the control inside upodate panel.
Priyagdpl wrote:
I used Update Panel, still it get refresh.
Do you have multiple update panel in the page ?
Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
-
Hi All, I would like to perform some validation on an entry into a text box in the TextChanged event without causing the entire page to refresh. In a Email-ID TextBox m checking whether that mailid is duplicate or not. I want to prevent user by entering duplicate mail-id. I used Update Panel, still it get refresh. any solution ??
You can use the Generic Handler for this purpose. Just put ur whole logic to identify the duplicate email then call this handler via xmlhttprequest.
var xmlhttp;
function InitXmlHttpRequest() {
xmlhttp = null; if (window.XMLHttpRequest) { // code for all new browsers xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { // code for IE5 and IE6 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
}
function CheckDuplicateEmail(url) {
InitXmlHttpRequest(); var handleStateChanged = function() { if (xmlhttp.readyState == 4) { // 4 = "loaded" if (xmlhttp.status == 200) { // 200 = OK try { alert("message from server : " + xmlhttp.responseText); } catch (e) { } } else { //alert("Problem retrieving XML data"); } } }; if (xmlhttp != null) { xmlhttp.onreadystatechange = handleStateChanged; xmlhttp.open("GET", url, true); xmlhttp.send(null); } else { //alert("Your browser does not support XMLHTTP."); }
}
now you can call this js method (CheckDuplicateEmail) on any event like textchangesd, lostfocus or keyup. Here the url is the Url of the Generic Handler u have created in previous step. The ResponseText will give you the data that u have returned from Generic Handler. I hope it gonna help u.