Articles → JavaScript → _Dopostback In Javascript
_Dopostback In Javascript
- First of all open visual studio and create a web application DissectDoPostBack (you can give any name to your web application).
- On the default.aspx page add a button control.
- Run the application.
- You can see a button which have added in the web form at design time.
- Right click on the web browser.
- Click View Source.
Click to Enlarge
- Now add a textbox in the form.
- Right click on the browser window and click View Source
Click to Enlarge
- Now add an attribute AutoPostBack = "true" in the textbox.
- Again run the application.
- Click on the textbox and type something in it. You can observe the submission of page validates AutoPostBack = "true" Fair enough.
- Now again right click on the browser and click View Source
Click to Enlarge
- On the head section of the page add a JavaScript function ClickButton
<script language = "javascript"
type = "text/javascript">
function ClickButton() {
return false;
} </script>
- On the page load add the following code
Button1.Attributes.Add("onclick", "return ClickButton();");
- Run the application
- Now in the ClickButton method add following
_doPostBack("TextBox1", "Test");
<script language = "javascript"
type = "text/javascript">
function ClickButton() {
_doPostBack("TextBox1", "Test");
return false;
} </script>
- Now again run the application.
- Click on the button.