后台:
protected void ibtnRegedit_Click(object sender, ImageClickEventArgs e)
{
if (!Page.IsValid || !CheckVCode())
return;
.......
}
———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
<script type="text/javascript">
var Ok = true;//false异步没回来不让提交,true异步没回来可以提交
function btnClick() {
var val = $("#<%=txtUName.ClientID %>").val();
if (val != "") {
$.post("/ashx/CheckUser.ashx", { "loginid": val },
function () {
if (arguments[0] == "1") {
$("#iE").attr("src", "/Images/dui.ico").show();
Ok = true;
Page_ClientValidate(null);//调用全局的方法
if (Page_IsValid) {
__doPostBack(‘ctl00$ContentPlaceHolder1$ibtnRegedit‘, ‘‘);//由LinkButton产生参数1:Name非ID
}
}
else {
$("#iE").attr("src", "/Images/cha.ico").show();
Ok = false;
}
}
, "text");
}
};
</script>
<asp:ImageButton ID="ibtnRegedit" runat="server" ImageUrl="~/Images/az-finish.gif" OnClick="ibtnRegedit_Click" /><asp:LinkButton ID="LinkButton1" runat="server" Visible="False"></asp:LinkButton><input type="button" name="btnSub" onclick="btnClick();" id="" value="完 成" style="height: 20px; width: 50px; border-style:solid none ;" />
网页源码:
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms[‘aspnetForm‘];
if (!theForm) {
theForm = document.aspnetForm;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>
网页源码:
<input type="image" name="ctl00$ContentPlaceHolder1$ibtnRegedit" id="ctl00_ContentPlaceHolder1_ibtnRegedit" src="../../Images/az-finish.gif" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ContentPlaceHolder1$ibtnRegedit", "", true, "", "", false, false))" style="border-width:0px;" /><input type="button" name="btnSub" onclick="btnClick();" id="" value="完 成" style="height: 20px; width: 50px; border-style:solid none ;" />
时间: 2024-11-05 19:42:22