为了美工操作经常把按钮用 <a></a> 链接来做,当“按钮”通过onclick调用了某方法执行__doPostBack时,在ie6,及某些浏览器下不触发或者时而不触发。
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
var confirmRefresh = function() {
if (confirm('.....')) {
__doPostBack('<%=lbtnPost.ClientID %>', '');
}
};
var confirmRefresh2 = function() {
if (confirm('.....')) {
__doPostBack('<%=lbtnPost.ClientID %>', '');
}
return false;
};
</script>
<script type="text/C#" runat="server">
protected void Page_Load(object sender, EventArgs e)
{
litFlag.Text = DateTime.Now.ToString();
}
protected void lbtnPost_Click(object sender, EventArgs e)
{
litFlag.Text = DateTime.Now.ToString();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:LinkButton ID="lbtnPost" runat="server" OnClick="lbtnPost_Click">Post</asp:LinkButton>
<a href="javascript:void(0);" onclick="confirmRefresh();">void刷新</a>
<a href="#" onclick="confirmRefresh();">href#刷新</a>
<a href="javascript:void(0);" onclick="return confirmRefresh2();">return false;刷新</a>
标识:<asp:Literal ID="litFlag" runat="server" />
</div>
</form>
</body>
</html>