JQUERY验证后未触发服务器事件 [英] Server event not fired after JQUERY validation

查看:53
本文介绍了JQUERY验证后未触发服务器事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是jquery的新手,请帮我解决以下问题。



我有一个模态弹出窗口,弹出窗口里面有两个asp按钮(搜索和关)。单击搜索按钮我要执行验证然后激活服务器按钮单击事件,单击关闭按钮我要关闭对话框。



问题面对:1。点击搜索jquery验证正在发生,但服务器端事件没有被触发。 2.单击关闭,对话框仅在第一次关闭,但在单击搜索按钮一次后,关闭的JQUERY不会被触发。



< b>下面是代码:



按钮打开对话框



I am new to jquery, Please help me resolve the below issue.

I have a modal popup and inside the popup i have two asp buttons(Search and close). Onclick of the search button i want to perform a validation and then fire the server button click event and on click of the close button i want to close the dialog.

Problems faced: 1. Onclick of search the jquery validation is happening but the server side event is not getting fired. 2. Onclick of close, the dialog is getting closed only for the first time but after click of the search button once, the close JQUERY is not getting fired.

Below is the code:

button to open dialog

<asp:Button ID="btnOpenDialog" runat="server" Text="Change"/>





jquery打开对话框





jquery to open dialog

$("[id*=btnOpenDialog]").live("click", function () {
$("#modal_dialog").dialog({
title: "Details",
modal: true,
width: "700px"              
});
return false;
}) 





带有asp按钮的对话框





The dialog with the asp buttons

<div id="modal_dialog" style="display:none">
<asp:Label ID="lblError" runat="server" Visible="true" ForeColor="Red"></asp:Label>                           

<asp:Label ID="lblLastName" runat="server" Text="Last Name"></asp:Label>
<asp:TextBox ID="txtLastName" Width="100px"  runat="server"></asp:TextBox>
<asp:Label ID="lblFirstName" runat="server" Text="First Name"> </asp:Label>                            
<asp:TextBox ID="txtFirstName" Width="100px" runat="server"></asp:TextBox>

<asp:Button ID="btnSearch" UseSubmitBehavior="false" runat="server" Text="Search" OnClick="btnSearch_Click"/>   
<asp:Button ID ="btnClose" Text="Close" runat="server"></asp:Button>      

</div>





btnSearch JQUERY





The btnSearch JQUERY

$("[id*=btnSearch]").live("click", function (e) {          
//e.preventDefault();
var firstName = $("#<%= txtFirstName.ClientID %>").val();
var lastName = $("#<%= txtLastName.ClientID %>").val();

if(firstName == "" & lastName == "")
{                          
$("#<%= lblError.ClientID %>").text("Enter minimum two characters in either first name or last name");              
return false;
}
else
{
$("#<%= lblError.ClientID %>").text("");
$("#hdnFirstNameInitiator").val($("#<%= txtFirstName.ClientID %>").val());
$("#hdnLastNameInitiator").val($("#<%= txtLastName.ClientID %>").val());  
return true;
}
})



关闭按钮JQUERY




The close button JQUERY

$("[id*=btnClose]").live("click", function (e) {
//e.preventDefault();              
$("#modal_dialog").dialog('close');
return true;
})





如果可能的话,请介绍一下jquery中的 appendTo 功能。



请帮助。



提前致谢,



Also if possible please brief me about appendTo function in jquery.

Please Help.

Thanks in advance,

推荐答案

[id * = btnOpe nDialog])。live( 点击 function (){
("[id*=btnOpenDialog]").live("click", function () {


#modal_dialog )。dialog({
title: Details
模态: true
width: 700px
});
return false ;
})
("#modal_dialog").dialog({ title: "Details", modal: true, width: "700px" }); return false; })





带有asp按钮的对话框





The dialog with the asp buttons

<div id="modal_dialog" style="display:none">
<asp:Label ID="lblError" runat="server" Visible="true" ForeColor="Red"></asp:Label>                           

<asp:Label ID="lblLastName" runat="server" Text="Last Name"></asp:Label>
<asp:TextBox ID="txtLastName" Width="100px"  runat="server"></asp:TextBox>
<asp:Label ID="lblFirstName" runat="server" Text="First Name"> </asp:Label>                            
<asp:TextBox ID="txtFirstName" Width="100px" runat="server"></asp:TextBox>

<asp:Button ID="btnSearch" UseSubmitBehavior="false" runat="server" Text="Search" OnClick="btnSearch_Click"/>   
<asp:Button ID ="btnClose" Text="Close" runat="server"></asp:Button>      

</div>





btnSearch JQUERY





The btnSearch JQUERY


[id * = btnSearch])。live( click function (e){
// e.preventDefault();
var firstName =
("[id*=btnSearch]").live("click", function (e) { //e.preventDefault(); var firstName =


这篇关于JQUERY验证后未触发服务器事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆