Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Validation Without Page Refresh .

Validation Without Page Refresh .

Scheduled Pinned Locked Moved ASP.NET
questionannouncement
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Priyagdpl
    wrote on last edited by
    #1

    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 ??

    A N 2 Replies Last reply
    0
    • P Priyagdpl

      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 ??

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • P Priyagdpl

        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 ??

        N Offline
        N Offline
        Nisha Agrawal
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups