码迷,mamicode.com
首页 > 其他好文 > 详细

普通按钮的另一种提交方式(调用后台事件)

时间:2014-05-08 00:44:32      阅读:281      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   code   java   tar   

bubuko.com,布布扣
后台:

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>
bubuko.com,布布扣
bubuko.com,布布扣
<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 ;" />
bubuko.com,布布扣
bubuko.com,布布扣
网页源码:

<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>
bubuko.com,布布扣
bubuko.com,布布扣
网页源码:

<input type="image" name="ctl00$ContentPlaceHolder1$ibtnRegedit" id="ctl00_ContentPlaceHolder1_ibtnRegedit" src="../../Images/az-finish.gif" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ContentPlaceHolder1$ibtnRegedit&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" style="border-width:0px;" /><input type="button" name="btnSub" onclick="btnClick();" id="" value="完 成" style="height: 20px; width: 50px; border-style:solid none ;" />
bubuko.com,布布扣

 

普通按钮的另一种提交方式(调用后台事件),布布扣,bubuko.com

普通按钮的另一种提交方式(调用后台事件)

标签:style   blog   class   code   java   tar   

原文地址:http://www.cnblogs.com/wjshan0808/p/3714489.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!