做使用__doPostBack后回来时遇到错误() [英] Encountering Error when doing post-back using __doPostBack()
本文介绍了做使用__doPostBack后回来时遇到错误()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我于JavaScript做后回来时,得到一个错误。在code是如下:
I am getting an error on javascript when doing post back. The code is as follows:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
function DoPostBack()
{
__doPostBack('Button2','My Argument');
}
</script>
</head>
<body>
<form id="form1" runat="server">
<input type="button" id="Button2" value="Press me" onclick="DoPostBack()" />
</form>
</body>
</html>
我收到以下错误:
I am getting the following error:
Line: 13
Error: Object expected
我不明白为什么这个错误即将到来。好心帮...
I can't understand why this error is coming. Kindly help...
推荐答案
您可以使用一个隐藏按钮做这个任务
you can use a hidden button to do this task
Button1.Attributes.CssAttributes.Add("Display","None");
隐藏按钮后,
您可以从JavaScript调用它的点击功能
you can call its click function from javascript
document.getElementById('<%=Button1.ClientID%>').click();
这将调用的button1_Click服务器
this will call Button1_Click on server
**记得设置 UseSubmitBehaviour = FALSE
来就非IE浏览器这项工作
** remember to set UseSubmitBehaviour=false
to make this work on non-IE browsers
希望帮助:)
这篇关于做使用__doPostBack后回来时遇到错误()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文