admin管理员组文章数量:1023104
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>
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>
Share
Improve this question
edited Dec 1, 2011 at 6:03
janakiakula
asked Dec 1, 2011 at 5:42
janakiakulajanakiakula
3171 gold badge5 silver badges14 bronze badges
5 Answers
Reset to default 1When doing a __doPostBack, you need to pass the control's UniqueID via javascript. ClientID will not work.
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/page.aspx/1082/dopostback-function/
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%>");
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
Please try to getElementById
this way
var btnlogout = document.getElementById('<%= lbtn_Logout.ClientID %>');
alert(btnlogout)
and test it again , it will work..
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>
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>
Share
Improve this question
edited Dec 1, 2011 at 6:03
janakiakula
asked Dec 1, 2011 at 5:42
janakiakulajanakiakula
3171 gold badge5 silver badges14 bronze badges
5 Answers
Reset to default 1When doing a __doPostBack, you need to pass the control's UniqueID via javascript. ClientID will not work.
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/page.aspx/1082/dopostback-function/
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%>");
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
Please try to getElementById
this way
var btnlogout = document.getElementById('<%= lbtn_Logout.ClientID %>');
alert(btnlogout)
and test it again , it will work..
本文标签: aspnetdopostback is not working in javascript functionStack Overflow
版权声明:本文标题:asp.net - __dopostback is not working in javascript function - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745569959a2156674.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论