OnClick事件不会触发,但OnClientClick会触发 [英] OnClick event doesn't fire but OnClientClick does
本文介绍了OnClick事件不会触发,但OnClientClick会触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在按钮单击上执行SP,该按钮单击也有OnClientClick,通过该按钮触发javascript。问题是OnClientClick工作正常,但是OnClick事件并没有得到任何帮助。
Javascript
I'm trying to execute a SP on the button click which also has OnClientClick through which a javascript is triggered. The problem is OnClientClick works properly but OnClick event doesn't get fire at all kindly help.
Javascript
function Redirect_Final()
{
display_inner_dropdown(false);
var Qstring,tid,bid,beid,bdid,r;
var content;
document.form1.method="post";
document.form1.action="Report_Card.aspx";
content = calculate();
content += '<br><table align=center cellpadding=1>'
content += '<tr><td colspan=2 align=left style="color: #FFFFFF; font-family: Arial; font-size: 8pt" bgcolor="#FF0000"><input type=checkbox id=ichk onclick=on_off();> <b>I Accept the above Information.</b> </td></tr>'
content += '<tr>'
content += '<td><input id=ibtnsubmit type=button class=mybutton disabled value="Final Submit" onclick=submitMe();></td>'
content += '<td><input type=button class=mybutton value=Cancel onclick=No_submit();></td>'
content += '</tr></table>'
showDialog('Confirmation',content,Global);
}
function submitMe() {
xmlHttp=ajaxOperation()
username = document.getElementById("hidusername").value;
testid = document.getElementById("hidtestid").value;
str = target + "?type=0&U=" + username + "&T=" + testid;
sendPage(xmlHttp,str);
//document.form1.action = "Report_Card.aspx?U=" + username + "&T=" + testid;
document.form1.submit();
}
function No_submit()
{
display_inner_dropdown(true)
hideDialog();
}
按钮的ASPX代码
ASPX code for button
<td style="height: 50px; text-align: right">
<asp:Button ID="btn_Submit" OnClientClick="if (!Redirect_Final()) {return false;}" Text=""
runat="server" CssClass="finishnormal" UseSubmitBehavior="False" Height="30px"
Width="94px" onmouseover="this.className='finishhover'" onmouseout="this.className='finishnormal'"
Style="left: 0px" OnClick="btn_Submit_Click" />
</td>
CS Code
CS Code
protected void Load_End_Timer()
{
sql = "sp_EndTime_New_LMS_Test '" + hidusername.Value + "'," + hidtestid.Value;
DBCon.Simple_InsUpdDel(sql, 3);
}
protected void btn_Submit_Click(object sender, EventArgs e)
{
Load_End_Timer();
}
推荐答案
嗨亲爱的,
i想你应该把你的按钮控件放在更新面板里面然后它将工作正常bcz onclient点击事件触发客户端,而onclick事件是服务器端事件。可能是你在onclient点击期间被调用的javascript方法回发的原因.....
尝试一下....
hi dear,
i think u should put ur button control inside update panel then it will work fine bcz onclient click event fires client side while onclick event is a server side event. may be ur javascript method that is being called during onclient click cause of postback.....
try it out....
这篇关于OnClick事件不会触发,但OnClientClick会触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文