Articles → JavaScript → _Dopostback In Javascript

_Dopostback In Javascript









  1. First of all open visual studio and create a web application DissectDoPostBack (you can give any name to your web application).
  2. On the default.aspx page add a button control.
  3. Run the application.
  4. You can see a button which have added in the web form at design time.
  5. Right click on the web browser.
  6. Click View Source.
  7. Picture showing the rendered html of the web page without _dopostback function
    Click to Enlarge



  8. Now add a textbox in the form.


  9. Right click on the browser window and click View Source
  10. Picture showing the rendered html of the web page without _dopostback function
    Click to Enlarge



  11. Now add an attribute AutoPostBack = "true" in the textbox.
  12. Again run the application.
  13. Click on the textbox and type something in it. You can observe the submission of page validates AutoPostBack = "true" Fair enough.
  14. Now again right click on the browser and click View Source
  15. Picture showing the rendered html of the web page with _dopostback function
    Click to Enlarge









  16. On the head section of the page add a JavaScript function ClickButton
  17. <script language = "javascript"
    type = "text/javascript">
      function ClickButton() {
    
        return false;
      } </script>


  18. On the page load add the following code
  19. Button1.Attributes.Add("onclick", "return ClickButton();");


  20. Run the application


  21. Now in the ClickButton method add following
  22. _doPostBack("TextBox1", "Test");




    <script language = "javascript"
    type = "text/javascript">
      function ClickButton() {
        _doPostBack("TextBox1", "Test");
        return false;
      } </script>


  23. Now again run the application.
  24. Click on the button.





Posted By  -  Karan Gupta
 
Posted On  -  Friday, May 21, 2010

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250