Reputation: 317
am calling __dopostback
function in javascript while closing event of browser but its not working in Chrome.
the same function is working in IE
can any one give me the solution.
<script type="text/javascript" language="javascript">
function doUnload()
{
var btnlogout = document.getElementById("ctl00_lbtn_Logout"); alert(btnlogout);
__doPostBack(btnlogout, '');
}
</script>
Upvotes: 3
Views: 6210
Reputation: 962
When doing a __doPostBack, you need to pass the control's UniqueID via javascript. ClientID will not work.
Upvotes: 1
Reputation: 8606
Please try to getElementById
this way
var btnlogout = document.getElementById('<%= lbtn_Logout.ClientID %>');
alert(btnlogout)
and test it again , it will work..
Upvotes: 0
Reputation: 504
dopostback(clientID, args)'s first parameter must be a control's clientid, it is a string , not object (of course string is object ) .. in your case , i assume that is 'ctl00_lbtn_Logout', pass the right params like :
__doPostBack('<%= downloadUp.ClientID %>', current_index);
if your control is server side control, change 'downloadUp' to your control's id , else you just need pass the id
Upvotes: 0
Reputation: 63956
Just do:
btnlogout.click();
since you already have a reference to the button and, by the way, don't get the element the way you are doing it; do this instead:
var btnlogout = document.getElementById("<%=btn_Logout.ClientID%>");
Upvotes: 0
Reputation: 9092
I think you should be passing the btnlogout
id as string (not sure if you have to remove the ctl00
thing since it's a child control) as the function expects text and it is probably resolved during the request on the server..
Take a look at this article: http://wiki.asp.net/page.aspx/1082/dopostback-function/
Upvotes: 0