Understanding the JavaScript __doPostBack Function
page 1 of 7
Published: 20 Jun 2006
Abstract
In this article we will look into the __doPostBack function of JavaScript. Read the article to find some insights about the function.
by Mohammad Azam
Feedback
Average Rating: 
Views (Total / Last 10 Days): 138884/ 2371

Introduction

It is quite amazing to note that only two of the ASP.NET web server controls cause a postback.  All the other controls use the JavaScript __doPostBack function to trigger the postback.  In this article you will learn about the __doPostBack function and how it works.


View Entire Article

Article Feedback

Title:  
Name:  
Url: ( Optional )
Comment:  
Please add 8 and 1 and type the answer here:

User Comments

Title: calender control   
Name: siva srinivas
Date: 9/7/2008 11:46:05 PM
Comment:
how to select a calender control into my ui
Title: Problem with this function   
Name: Srinivas
Date: 7/16/2008 3:23:50 AM
Comment:
\
\
\
\
Title: SharePoint   
Name: Shams
Date: 7/7/2008 5:19:16 PM
Comment:
I am new to this function __doPostBack
Title: SharePoint   
Name: Roberto
Date: 7/3/2008 9:26:57 PM
Comment:
I've been able to use __doPostBack within SharePoint. This function when called from client-side script and combined with a custom web part makes it possible to get past some SharePoint limitations.

http://www.tributarysoft.com
Title: Security message   
Name: MV
Date: 6/10/2008 11:48:35 AM
Comment:
I am getting a security message whenever the dopostback is called for a calendar control from a button. Can I send you the message and see if you have come across this message before?

Thanks. MV
Title: pagination   
Name: john
Date: 5/25/2008 4:46:32 AM
Comment:
don't make each paragraph on a new page to increase your stats or you will lose viewers like you will lose me if i continue seeing this
Title: excellent explanation   
Name: Sandesh Kadam
Date: 4/10/2008 9:20:49 AM
Comment:
Greetings, This is nice peice of explanation for the postback. But for certain reason i didn't find it helpful in my situation as its not covered in the article. And i post this message to all the champs, if possible please tel me how would we do the same postback excersie having the forms action allready defined? i shall wait to read from you guys...

Sandesh
Title: example   
Name: name_example
Date: 4/8/2008 4:03:52 AM
Comment:
it example
Title: i want script like this   
Name: anmoldeep
Date: 2/26/2008 9:09:20 AM
Comment:
javascript:__doPostBack('dnn$dnnSOLPARTMENU$ctldnnSOLPARTMENU','56')
Title: er controls.   
Name: er controls.
Date: 2/26/2008 5:27:53 AM
Comment:
er controls.
Title: __doPostBack()   
Name: Ramesh Ramalingam
Date: 2/17/2008 3:09:11 AM
Comment:
Nice artical... It is pretty clear...
Title: __doPostBack()   
Name: amit
Date: 2/10/2008 3:39:09 AM
Comment:
I want to know this
Title: __doPostBack()   
Name: Rudra
Date: 1/29/2008 4:19:31 AM
Comment:
Good artical
Title: Improve   
Name: Muthu
Date: 1/17/2008 6:44:28 AM
Comment:
u do u have next button for such a same article
Title: Can i call the __doPostBack in a href   
Name: Vimal
Date: 1/9/2008 3:52:48 AM
Comment:
Hai i tried to call the __doPostBack event in a href from client side script, but i got an error 'object expected'.

var link = document.createElement('A');
link.setAttribute('href','javascript:__doPostback("TESTTgt","TESTArg")');
Title: Mr   
Name: Ajit
Date: 1/3/2008 10:05:41 AM
Comment:
Very nice article, very easy to understand.
Title: cool   
Name: Big Fat Al
Date: 12/19/2007 8:18:10 PM
Comment:
Cheers Mate - nice one - only takes a few minutes to gain some clarity but too often we rush on ahead without stopping to think. Thanks for the quick n easy read, especially the bit about buttons not calling __DoPostBack... solved my problem for the morning.. onto the next one!
Title: Thnx   
Name: Yusuf Squires
Date: 12/4/2007 3:12:51 PM
Comment:
Really helpful. Thnx!!!!
Title: __doPostBack('btnCntrl','')   
Name: Nac
Date: 11/28/2007 6:13:09 AM
Comment:
if this called in javascript function alone it works fine
but if function contains some other javascript statements
before this stmt, it is not working properly,
may I know why this is happening??
Title: Fantastic Article   
Name: The Computer Doctor
Date: 11/26/2007 11:21:26 AM
Comment:
A very very good article.
Title: Good article   
Name: Everett Liu
Date: 11/20/2007 4:23:11 AM
Comment:
I am a new comer, I like this, I will come here again.
Title: Lame.   
Name: Brittany
Date: 11/9/2007 5:23:04 AM
Comment:
Wow, that told me absolutely nothing.

Tell me straight to the point how to make it so javascript won't be lame and let me view all internet pages.

That's all I want to know.
Title: Google Map control   
Name: Moe
Date: 11/5/2007 1:44:59 AM
Comment:
HI, is there a .net control which can load gmarkers dynamically ? like this site http://www.publicbar.com
does ?
Title: I HATE JAVA   
Name: APPLE
Date: 10/4/2007 8:47:18 PM
Comment:
I HATE JAVA EVERY TIME I CLICK SOMETHING IT POPS UP I GET PISSED OF
Title: BACK   
Name: MARLYN
Date: 10/4/2007 4:50:10 PM
Comment:
its good java
Title: photos   
Name: GF
Date: 10/4/2007 4:45:10 PM
Comment:
the java thing keeps poping up every time i want to change my default and it will not let me delete my pictures and when i click fix java it does not work
Title: comments   
Name: navjot
Date: 9/13/2007 5:22:52 AM
Comment:
dis was very informative article......good work!!!!
Title: What's the difference between...   
Name: JS
Date: 8/21/2007 2:45:15 PM
Comment:
my drop down list wont change because when I debug, in the _doPostBack function, !theForm.onSubmit returns false and (theForm.onsubmit() returns false.

what's the difference between onSubmit and onSubmit()?
Title: Mr.   
Name: Amd
Date: 8/13/2007 4:45:01 AM
Comment:
Nice!!!!!!!!
Title: how to change event argument of linkbutton via javascript   
Name: anjali
Date: 7/21/2007 11:57:12 AM
Comment:
i have a link button which has CommandArgument property set to "lbOne". When i click link button i want to change its CommandArgument property to "lbTwo" via javascript(not in code behind) How can i do that? Any help greatly appreciated...
Title: Excellent Article!   
Name: Stuart
Date: 7/17/2007 8:15:20 AM
Comment:
Thanks for a very informative article. This not only helped me to understand the __EVENTARGUMENT but has given me enough food for thought to solve an issue I've been having with postbacks when trying to use a modulpopupextender.

Keep up the good work!
Title: Calling __doPostBack without link button or autopostback set to true   
Name: Josh
Date: 7/12/2007 8:35:39 PM
Comment:
If you want to use __doPostBack without setting the autopostback to true or without adding a link button add this bit of code to your pageload. This will create the reference to the function for you

Page.GetPostBackEventReference(this);
Title: dal   
Name: M. Kausar
Date: 7/12/2007 1:58:34 AM
Comment:
this good
Title: Shrivastav   
Name: Deepak
Date: 6/18/2007 9:36:11 AM
Comment:
Very good way to teach the things.Good artical,but could have been into more depth.
Title: Good artical But I Need Some other help please   
Name: Spatel
Date: 6/1/2007 2:57:21 AM
Comment:
I am Using Asp.net2.0.I wan't to get Control type in Java Script So please tell me How I Know that Control Which comes in Java Script is Textbox,DropDown,or any other.

Thanks in Advance.
Title: thanks   
Name: pravin nair
Date: 5/28/2007 10:29:47 AM
Comment:
It was a really good article.I really understood the concepts of __doPostBack();
Title: Thankyou   
Name: Si
Date: 5/25/2007 9:54:10 AM
Comment:
Thanks for a clear and concise explanation of __doPostBack():)
Title: Need help   
Name: Priya
Date: 4/26/2007 5:39:10 AM
Comment:
Good article. Can you tell me how do I do a postback on another page to reflect some chnages when I click one button from my current active page?
Title: Waste   
Name: Shi
Date: 4/19/2007 5:45:07 AM
Comment:
Waste article, no use
Title: heeee   
Name: heeee
Date: 3/30/2007 4:39:24 PM
Comment:
let me know how to use __doPostback with out keeping link button or autopostback='true' on dropdownlist
Title: javascript:__doPostBack('ViewFinancialAid','')   
Name: Gary Lagstrom Jr
Date: 3/14/2007 7:09:57 AM
Comment:
This pop-up is blocked on my financial dispersion awards for my graduate program at Walden University. It is an image button that shows dispesement dates for my student loans. I need to be able to see this image. Even though I have the pop-up function disabled it still blocks the image. What do I do?

Send reply to:
gary_lagstrom@hotmail.com

Thank-you for your time:)
Title: Good Article it may help in my projet   
Name: sandesh
Date: 2/17/2007 1:21:22 AM
Comment:
Good Article it may help in my projet,

But where i will get the answers of these questions asked by others

Plz give me reply at sandesh_daddi@rediffmail.com
Title: Why does it use javascript:setTimeout   
Name: Ornit
Date: 11/5/2006 5:40:52 AM
Comment:
Why does it use javascript:setTimeout for exceuting _doPostBack instead of calling it directly?
Title: javascript:-doPostBack(imageLogin Button)   
Name: Sarah
Date: 10/20/2006 12:46:09 PM
Comment:
What does that mean? Am trying to get into my web mail and cannot. That is the message that I get. I do not have a computer background and my ISP Tech is no help. Can you explain that message to me? Thank you
Title: Find out eventtarget and eventargument on clientside?   
Name: nico
Date: 9/26/2006 7:11:01 AM
Comment:
Hi,

just found your article. thank you for your work. i'd need to find out eventtarget and eventargument on the client side. we are doing some validation on the side, every time the form is submitted. in asp 1.1 wh had to overwrite dopostback AND onsubmit. now in .net 2.0 onsubmit is called every time and we don't need to overwrite dopostback anymore. unfortunately we need to know, which control caused the postback. do you have an idea how to get this information within onsubmit?

regards
nico
Title: Thanks   
Name: AzamSharp
Date: 8/17/2006 2:25:00 PM
Comment:
I am glad that you liked the article!
Title: MCAD   
Name: Gene Naden
Date: 8/17/2006 2:21:48 PM
Comment:
The article on Understanding the __doPostBack function was very helpful.
Title: Great!!   
Name: Irfan
Date: 8/1/2006 5:47:11 AM
Comment:
Great..atleast we got an idea of javascript dopostback function..

Nice Explaination
Title: Thanks   
Name: Rob
Date: 8/1/2006 5:13:55 AM
Comment:
I've been searching for a way to send client-side inputs (through a DIV/contentEditable) blended on a page with server-side controls for inclusion in a database. The ability to send 'My Argument' (or whatever text) through this method works great.

Thanks
Title: How to fin button that caused postback   
Name: me
Date: 7/14/2006 5:46:36 PM
Comment:
Pravin:
This is where you can find out which button caused the postback:
http://www.ryanfarley.com/blog/archive/2005/03/11/1886.aspx
Title: How can I cause a submit button callback????   
Name: Deepak
Date: 7/13/2006 1:58:20 AM
Comment:
Hi
Conider the following code
[CODE]
<asp:button id=btnServer OnClick=btnServer_Click />

[/CODE]
Question:
I want to write a client side function (replace ...) such that it allows to call the server side btnServer_Click function. How can I do that?
Title: Firefox problem   
Name: Scott Hooper
Date: 6/29/2006 11:26:10 PM
Comment:
This works beautifully in IE, but doesn't work for firefox. I am pretty sure it's a problem with the syntax of:
theForm.__EVENTTARGET.value = eventTarget;
Any suggestions on how to correct?
Thanks,
sfhooper@expectra.com.au
Title: Finding button that caused postback   
Name: Pravin Singh
Date: 6/29/2006 7:43:57 AM
Comment:
In LISTING 5, you iterated through the form collection for finding the button control but if for example my page has multiple submit buttons - how do we find out which button caused the postback?

Product Spotlight
Product Spotlight 
Learn More
.NET Tools
asp.net shopping cart
asp.net chart control






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2008 ASPAlliance.com  |  Page Processed at 10/13/2008 12:58:01 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search