简体   繁体   English

使用FireFox时,updatepanel中的asp.net按钮无法触发Jquery函数

[英]asp.net button inside updatepanel not firing Jquery function on click when using FireFox

Jquery eddited as suggested and the problem is still the same FireFox just doesnt accept these Jquery jQuery按建议进行编辑,问题仍然相同FireFox只是不接受这些Jquery

When using chrome everything works fine but with FireFox the buttons does not fire query function when clicked. 使用chrome时,一切正常,但使用FireFox时,单击按钮不会触发查询功能。 Here is one button example in my web app that is not firing when using FireFox: 这是我的Web应用程序中的一个按钮示例,该示例在使用FireFox时不触发:

Inside Inquiry div there is a button with id "izprati" and when it is clicked it sends some data to a mail the code is inside the .cs page but also when its clicked using Jquery it closes the div with id "inquiry" and FadesIn the div with id "inquiryAnswer".When using chrome everything works as expected but when using FireFox the Inquery div doesnt FadeOut on click and the InqueryAnswer div is not fading In. 在查询div内,有一个ID为“ izprati”的按钮,单击该按钮会将一些数据发送到邮件中,代码位于.cs页内,但是当使用Jquery单击该代码时,它也会关闭ID为“ inquiry”和FadesIn的div使用chrome时,一切正常,但是使用FireFox时,Inquery div不会在单击时淡出,InqueryAnswer div不会淡入。

the "izprati" asp.net button is inside updatePanel with asyncPostBackTrigger “ izprati” asp.net按钮位于带有asyncPostBackTrigger的updatePanel内部

HTML: HTML:

<div id="Inquiry" class="inquiry">
           <img id="closeY" class="close" src="Logos/closeY.png" />

           <table   style="width:60%;">
               <tr>
                   <td>
                    <asp:Label runat="server" ID="l1" style="font-size:30px;"> Запитване </asp:Label>

                   </td>
               </tr>
               <tr>
                   <td>
                      <asp:Label ID="l2" runat="server" style="font-size:22px;width:100px;">Имейл</asp:Label>
                   </td>
                   <td><asp:TextBox ID="t1" runat="server" style="font-size:22px;width:300px;"></asp:TextBox></td>
                   <td><asp:Label ID="Label1" runat="server" style="color:red"></asp:Label></td>

               </tr>
               <tr>
                   <td><asp:Label ID="l6" runat="server" style="font-size:22px;width:100px;">Име*</asp:Label> </td>
                   <td><asp:TextBox runat="server" ID="t6" style="font-size:22px;width:300px;"></asp:TextBox></td>
               </tr>
                <tr>
                   <td>
                      <asp:Label ID="l3" runat="server" style="font-size:22px;width:100px;">Тема</asp:Label>
                   </td>
                   <td><asp:TextBox runat="server" ID="t2" style="font-size:22px;width:300px;"></asp:TextBox></td>
                     <td><asp:Label ID="Label2" runat="server" style="color:red"></asp:Label></td>
               </tr>
                <tr>
                   <td>
                      <asp:Label ID="l4" runat="server" style="font-size:22px;width:100px;">Текст</asp:Label>
                   </td>
                   <td><textarea runat="server" id="TextArea" style="height:200px;width:300px;max-height:200px;max-width:300px;"></textarea></td>
                     <td><asp:Label ID="Label3" runat="server" style="color:red"></asp:Label></td>

               </tr>
               <tr>
                   <td>
                       <asp:Label runat="server" ID="l5" style="font-size:22px;width:100px;">Телефон</asp:Label>
                   </td>
                   <td>
                       <asp:TextBox ID="telephone" runat="server" style="font-size:22px;width:300px"></asp:TextBox>
                   </td>

               </tr>
               <tr>
                   <td></td>
                   <td><asp:Button id="izprati" runat="server" style="width:300px;height:50px" OnClick="izprati_Click" Text="Изпрати" /></td>
                    <td><asp:Label runat="server" ID="answer"></asp:Label></td>

               </tr>

           </table>
           <img src="Logos/q.jpg" style="position:absolute;right:50px;top:20px;height:200px;width:300px;" />

       </div>
       <div class="inquiryAnswer" id="inquiryAnswer">
           <img id="inquiryAnswerClose" class="close" src="Logos/closeY.png" />
                <div style="position:absolute;bottom:40px;right:15px;left:15px;" id="ThankYou" runat="server">
           Благодарим Ви за запитването! Член на нашият екип ще се свърже с Вас до 24 часа.
               </div>
       </div>
 <Triggers>

                     <asp:AsyncPostBackTrigger ControlID="izprati" EventName="Click" />

                   </Triggers>

CSS: CSS:

.inquiry {
position:fixed !important;
position:absolute;
top:10vh;
right:0;
bottom:0;
left:10vw;
width:80vw;
height:80vh;
background-color:white;
padding:10px;
z-index:10;
display:none;
-webkit-box-shadow:  0 0 3px 1px black;
box-shadow:          0 0 3px 1px black;

}
.inquiryAnswer {
position:fixed !important;
position:absolute;
top:30vh;
right:0;
bottom:0;
left:35vw;
width:30vw;
height:15vh;
background-color:white;
padding:25px;
z-index:10;
display:none;
-webkit-box-shadow:  0 0 3px 1px black;
box-shadow:          0 0 3px 1px black;
text-align:center;
font-size:21px;
font-weight:bold;
}

Jquery: jQuery:

<script>
        $(document).ready(function () {

            $("#izprati").click(function () {
                $("#inquiryAnswer").fadeIn(1000);
                $(".inquiry").fadeOut(1000);
                $("#answer").text("Благодарим Ви за запитването! Член на нашият екип ще се свърже с Вас до 24 часа.");
                $('<%=t1.ClientID %>').val("");
                $('<%=t2.ClientID %>').val("");            
                $('<%=t6.ClientID %>').val("");
                $('<%=TextArea.ClientID %>').val("");
                $('<%=telephone.ClientID %>').val("");
            });
            $("#inquiryAnswerClose").click(function () { $(".inquiryAnswer").fadeOut(1000); });
        });
    </script>

Eddited Jquery to : 将Jquery简化为:

<script>
function BindControlEvents() {

            $('#StayOpen1').click(function () {
                $("#situationalpanel").fadeOut(1000);
                $('#DeluxeR').fadeOut(1000);
                $('#OneBedR').fadeOut(1000);

                $('#standartR').fadeIn(1000);
            });

            $('#StayOpen2').click(function () {
                $("#situationalpanel").fadeOut(1000);
                $('#standartR').fadeOut(1000);
                $('#OneBedR').fadeOut(1000);
                $('#DeluxeR').fadeIn(1000);
            });

            $('#StayOpen3').click(function () {
                $("#situationalpanel").fadeOut(1000);
                $('#standartR').fadeOut(1000);
                $('#DeluxeR').fadeOut(1000);
                $('#OneBedR').fadeIn(1000);
            });







            $(
                '#AboutUs , #NavButton1 , #NavButton2 , #NavButton7, #NavButton3 , #NavButton4 , #NavButton5 , #NavButton6 , #NavButton7, #LinkButton4 , #LinkButton5, #LinkButton6, #LinkButton7, #LinkButton8, #LinkButton9, #LinkButton10, #LinkButton11, #LinkButton12, #LinkButton13, #LinkButton14, #LinkButton15, #LinkButton16, #LinkButton17, #LinkButton18, #LinkButton19, #LinkButton20'
                ).click(function () {
                    $('#standartR , #DeluxeR , #OneBedR').fadeOut(1000);
                });



            $("#LinkButton4").click(function () {
                $("#map1").fadeIn(500);
            });
            $("#AboutUs , #NavButton3 , #NavButton4 , #NavButton5 , #NavButton6 , #StayOpen1 , #StayOpen2 , #StayOpen3 , #LinkButton17").click(function () {
                $("#map1").fadeOut(100);
            });
            $("#izprati").click(function () {
                $("#inquiryAnswer").fadeIn(1000);
                $(".inquiry").fadeOut(1000);
                $("#answer").text("Благодарим Ви за запитването! Член на нашият екип ще се свърже с Вас до 24 часа.");
                $('<%=t1.ClientID %>').val("");
            $('<%=t2.ClientID %>').val("");
            $('<%=t6.ClientID %>').val("");
            $('<%=TextArea.ClientID %>').val("");
            $('<%=telephone.ClientID %>').val("");
        });
            $("#inquiryAnswerClose").click(function () { $(".inquiryAnswer").fadeOut(1000); });

     }

     //Initial bind
     $(document).ready(function () {
         BindControlEvents();

     });

     //Re-bind for callbacks
     var prm = Sys.WebForms.PageRequestManager.getInstance();

     prm.add_endRequest(function () {
         BindControlEvents();
     });


</script>

JQuery selectors doesn't work with update panel. jQuery选择器不适用于更新面板。 You need some work-around to implement the functionality. 您需要一些解决方法来实现该功能。 Here are couple of links to help you out - 这里有几个链接可以帮助您-

jQuery $(document).ready and UpdatePanels? jQuery $(document).ready和UpdatePanels?

My jquery selectors doesn't work after update panel in content page 内容页面中的“更新”面板后,我的jquery选择器不起作用

Try this jquery script: 试试这个jQuery脚本:

<script type="text/javascript">
    $("body").on("click", "#button1", function () {
        alert("Button was clicked.");
    });
</script>

Reference - click here check the link and get more detail about the issue 参考- 单击此处检查链接,并获得有关该问题的更多详细信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ASP.net按钮点击不使用Jquery模态对话框触发 - ASP.net Button on click not firing using Jquery Modal Dialog 使用UpdatePanel在Firefox中触发ASP.NET DropDown SelectedIndexChanged - ASP.NET DropDown SelectedIndexChanged not firing in Firefox with UpdatePanel 单击一个ASP.NET按钮(位于UpdatePanel内部)以清除文本框(位于UpdatePanel外部) - Click an ASP.NET Button (locate inside an UpdatePanel) to clear a TextBox (locate outside of the UpdatePanel) 使用asp.net中的Updatepanel的jQuery函数不起作用 - jquery function not working using Updatepanel in asp.net 在UpdatePanel中的FireFox中,asp.net LinkBut​​ton的响应速度极慢 - Extremely laggy Responsiveness of asp.net LinkButton in FireFox inside a UpdatePanel ASP.NET按钮单击事件未触发 - An ASP.NET button click event is not firing asp.net jquery更改updatePanel中的html - asp.net jquery change html inside updatePanel 弹出窗口中放置的Web用户控件的按钮单击事件未触发-Asp.net Webforms - Button Click Event of Web User Control that is placed inside a popup not firing - Asp.net Webforms 在asp.net中单击按钮时调用jQuery函数 - Call jQuery function on button click in asp.net asp.net按钮单击不通过jquery在隐藏字段中触发大量数据 - asp.net button click not firing with large amount of data in hidden field through jquery
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM