function ConfirmActive()
{
if(<%= TimeSheetFlag %> != -100) //do not save or cancel about the previous item
{
if (confirm("Are you sure you want to delete the custom search?") == false)
{
SetCancel();//请注意这儿
}
}
return true;
}
function SetCancel()
{
alert("sdd");//这儿
var cancel = document.getElementById("cmdSetCancel"); //服务器端控件
cancel.click(); //调用点击事件.
alert("add");////这儿
}
问题是这样的:如果我把alert(sdd)...add加上,服务器端事件就可以正常触发,如果去掉就不触发了.真是奇怪!
请帮忙.
{
if(<%= TimeSheetFlag %> != -100) //do not save or cancel about the previous item
{
if (confirm("Are you sure you want to delete the custom search?") == false)
{
SetCancel();//请注意这儿
}
}
return true;
}
function SetCancel()
{
alert("sdd");//这儿
var cancel = document.getElementById("cmdSetCancel"); //服务器端控件
cancel.click(); //调用点击事件.
alert("add");////这儿
}
问题是这样的:如果我把alert(sdd)...add加上,服务器端事件就可以正常触发,如果去掉就不触发了.真是奇怪!
请帮忙.
{
alert("sdd");//这儿
var cancel = document.getElementById("cmdSetCancel"); //服务器端控件
cancel.click(); //调用点击事件.
alert("add");////这儿
}换成
function SetCancel()
{
document.all.cmdSetCancel.click();
}
这样可以吗?
{
alert("sdd");//这儿
var cancel = document.getElementById("cmdSetCancel"); //服务器端控件
cancel.click(); //调用点击事件.
alert("add");////这儿
}换成
function SetCancel()
{
document.all.cmdSetCancel.click();
}
这样可以吗?
http://www.81M.Net网页设计超市,你的问题或许里面能找到
Http://Free.81M.Net免费空间站
<head>
<title>测试JS脚本</title>
<script language="javascript">
function goCK()
{
if(confirm("Are you sure you want to delete the custom search?") == false)
{
setCK();
}
}
function setCK()
{
document.all.btn2.click();
}
</script>
</head>
<body>
<input type="button" value="第一" onClick="goCK();">
<input type="button" id="btn2" value="第二" onClick="alert('你好');">
</body>
</html>
.cs
protected System.Web.UI.WebControls.ImageButton ImageButton1;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
ImageButton1.Attributes.Add("onclick","return CC();");
} #region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.ImageButton1.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton1_Click);
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
int xx = 1;
} private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
int yy = 2;
}.aspx<script language = "javascript">
function CC()
{
//alert("sdd");
document.all.Button1.click();
//alert("add");
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:ImageButton id="ImageButton1" style="Z-INDEX: 101; LEFT: 384px; POSITION: absolute; TOP: 224px"
runat="server"></asp:ImageButton>
<asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 544px; POSITION: absolute; TOP: 344px" runat="server"
Text="Button"></asp:Button>
</form>