按钮单击在更新面板中不起作用 [英] button click is not working in update panel

查看:63
本文介绍了按钮单击在更新面板中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我在更新面板按钮单击事件方面遇到问题.
我有一个称为Test.Master的母版页,它具有一个更新面板和一个位于更新面板旁边的占位符.和两个内容占位符位于更新面板之外.
现在我有一个名为Test.aspx的网页,它具有一个菜单控件和一个带有一个占位符的更新面板.为此,在服务器端,基于所选菜单项,我正在其中加载不同的不同用户控件.例如:如果我单击menuitem1,则需要用test1.ascx加载;如果我单击menuitem2,则需要用test2.ascx加载.在test2.ascx中,我有三个文本框和一个向其提交值的按钮,现在的问题是我单击按钮时,按钮单击事件未触发.

当我第二次提交时会触发.谁能帮我解决这个问题.

这是我的代码:
Test.Master

Hi all,
i have a issue with update panel button click event.
I have a master page called Test.Master which have a update panel and a place holder in side the update panel. and two content placeholders which are out side the update panels.
now i have a webpage called Test.aspx which have a menu control and one update panel with one place holder. for this at server side based upon the selected menu item i am loading different different user controls in that. for example: if i click menuitem1 it need to load with test1.ascx and if i clicks on menuitem2 it need to load with test2.ascx. here in test2.ascx i have three textboxes and one button to submit the values to now the problem is i click on the button the button click event is not get fire.

it fires when i submit 2nd time. can any one please help me to solve this.

here is my code:
Test.Master

<div id="menu" class="menupanel" style="display:none;width: 800px;" align="center">
                <asp:ContentPlaceHolder ID="menupanel"  runat="server">        
               
            </div>
          
         <asp:UpdatePanel ID="UpdatePanel3" runat="server"  UpdateMode="Conditional"   ChildrenAsTriggers="true"  >
            <contenttemplate>
               <asp:PlaceHolder  ID="PlaceHolder1" runat="server">
            </contenttemplate>
           
        
  
            <div id="removed" class="removedpanel" style="display:none;width: 800px;" align="center">
                 <asp:ContentPlaceHolder  ID="ContentPlaceHolder1" runat="server">
        
        
            </div>


来自Test.aspx的代码:


code from Test.aspx:

<asp:UpdatePanel ID="UpdatePanel3" runat="server"  UpdateMode="Conditional"   ChildrenAsTriggers="true"  >
           <contenttemplate>
             <asp:PlaceHolder  ID="PlaceHolder1" runat="server">
           </contenttemplate>


来自Test1.ascx的代码:


code from Test1.ascx:

<asp:UpdatePanel ID="UpdatePanel3" runat="server"  UpdateMode="Conditional"   ChildrenAsTriggers="true" >
<contenttemplate>


                <asp:Label ID="lblOpwd" runat="server" Text="Old Password"></asp:Label>

            <td>
                :
         </td>
            <td>
                <asp:textbox ID="txtOpwd" runat="server" Text=""></asp:textbox>;
               <br />

                <asp:Label ID="lblNpwd" runat="server" Text="New Password"></asp:Label>
          <asp:textbox ID="txtNpwd" runat="server" Text=""></asp:textbox>
                    <br />

          <asp:Label ID="lblCpwd" runat="server" Text="Confirm Password"></asp:Label>
           <asp:textbox ID="txtCpwd" runat="server" Text="" ></asp:textbox>

       <asp:button  ID="btnUpdate" runat="server" Text="Update"
                  OnClientClick="javascript:showHelloWorld()"  Width="84px"></asp:button>
 <asp:Label ID="lblStatus" ForeColor="Red" runat="server">
               </td></contenttemplate>



预先感谢,
Sindhu.A



Thanks in advance,
Sindhu.A

推荐答案

看起来click事件在更新面板中起作用,但是您试图打开一些警报,因此它不起作用.

你必须做点其他事情

It looks like the click event is working inside the update panel but you are trying to open some alert so it is not working.

You have to do something else

string showHelloWorld = "alert(''Hello World'');";

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "msg", showHelloWorld, true);



并将其写入点击事件



and write this in the click event


这篇关于按钮单击在更新面板中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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