AjaxModalPopupExtender会在首次单击后显示弹出窗口,但随后在随后的调用中将不触发按钮单击事件 [英] AjaxModalPopupExtender displays the Popup after first click but then on subsequent calls without firing button click event

查看:58
本文介绍了AjaxModalPopupExtender会在首次单击后显示弹出窗口,但随后在随后的调用中将不触发按钮单击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

当用户单击Gridview中的放置"按钮时,我必须显示一个弹出窗口,请记住,当用户单击放置按钮时,我必须在模块级变量中捕获commandArgument的值,因此我可以在数据库中更新它.

现在,当页面显示并且用户单击 Place 按钮时,页面Postback to server然后出现弹出窗口,同时我在后面的代码中捕获button的commandargument值.

但是,从第二次开始第一次单击后,单击按钮将显示弹出窗口,而不在服务器上发送页面.

也就是说,它不会触发 Place 按钮的onClick事件,并且模块级别变量中的值保持不变.

之后,如果用户从弹出菜单中选择确定"按钮,它将在第一次调用 Place 按钮时更新在模块级别变量中设置的值.

请帮我该怎么办?

我的代码有任何错误吗?

Dear All,

I have to display a popup when user clicks on Place button inside a Gridview and please remember it that as user clicks the Place button, I have to capture the value of commandArgument in a module level variable so that I can update it in Database.

Now as and when page displays and user clicks the Place button the page Postback to server and then popup appears and at the same time I capture the value of commandargument of button in code behind.

But, after the first click that is from 2nd time click of button displays the popup without sending the page on server.

That is it''s not firing the onClick event of Place button and the value in module level variable remains unchanged.

After that if user selects Ok button from popup it updates the value which sets in the module level variable when the Place button called at first.

Please help me what should I do?

Is there any mistake in my code?

<GridView id= "Grd"  runat="server" AutoGenerateColumns="false" CssClass="GridStyle" 

           HeaderStyle-Font-Size="Small" Width="960" Visible="false">
          <columns>          

          'Columns goes here          
          <asp:TemplateField HeaderText="Action" HeaderStyle-Width="310px" ItemStyle-HorizontalAlign="Left">
          <itemtemplate>
              <asp:Button ID="btnDelete" runat="server" Text="Delete" OnClick="btnDelete_Click" 

              CommandArgument='<%#Eval("intHireEnquiryID") %>' />
              <asp:Button ID="btnPlace" runat="server" Text="Place" OnClick="btnPlace_Click"  

              CommandArgument='<%#Eval("intHireEnquiryID") %>' />
              <ajaxtk:ModalPopupExtender  runat="server" ID="actPopup" TargetControlID="btnPlace" 

              PopupControlID="pnlPopup" CancelControlID="btnCancel" >
              
          </itemtemplate>
          
          </columns>   


在面板中,我有两个按钮PlaceFinal和取消",用于最终放置和取消请求.

在后面的代码中,我将其称为:-


In Panel I have two buttons PlaceFinal and Cancel which are used to Finally place and cancel the request.

In Code Behind i call it as : -

Dim popup As New AjaxControlToolkit.ModalPopupExtender
        Dim i As Integer
        For i = 0 To Grd.Rows.Count - 1
            popup = Grd.Rows(i).FindControl("actPopup")
            popup.Show()
        Next
        pnlPopup.Visible = True



请帮帮我.

在ajax中是否有任何问题,或者我必须添加任何属性以触发位置"按钮单击事件?

请帮忙.
任何人都可以帮忙.

我无法获得任何解决方案,请帮助.



Please help me.

Is there any problem in ajax or i have to add any attribute to fire the event of Place button click?

Please help.
Any one please help.

I could not get any solution please help.

推荐答案

您好,

1)不要将Modalpopup分配给按钮名称"Place".
2)将另一个按钮作为虚拟按钮应用扩展器,然后...


3)在Gridview行命令事件中...
Hi,

1)Dont Assign Modalpopup to button name "Place"..

2)Take another Button as Dummy button Apply Extender to it then ...


3)In Gridview Row Command Event...
<pre lang="c#">
  
Gridview_Row_Command_Event()
{
   
if (e.CommandName == "place")
        {
           

            Button1_ModalPopupExtender.Show();
 
        }
}


< gridview id ="Grd" runat ="server" autogeneratecolumns ="false" cssclass ="GridStyle">
HeaderStyle-Font-Size ="Small" Width ="960" Visible ="false">
<列>

''专栏在这里
< asp:templatefield headertext ="Action" headerstyle-width ="310px" itemstyle-horizo​​ntalalign ="Left" xmlns:asp =#unknown">
< itemtemplate>
< asp:button id ="btnDelete" runat ="server" text ="Delete" onclick ="btnDelete_Click">
CommandArgument =''<%#Eval("intHireEnquiryID")%>''/>
< asp:button id ="btnPlace" runat ="server" text ="Place" onclick ="btnPlace_Click">
CommandArgument =''<%#Eval("intHireEnquiryID")%>''/>








删除在gridview内部获取的modalpopupextender并将其保存在如下所示的更新面板中,并记住将modalpopupextender的TargetControlId从实际按钮删除为页面上没有用的虚拟按钮并将其隐藏.此btnDummy仅用于消除未为modalpopup定义targetcontrolid且没有任何内容时引发错误的错误.


< asp:updatepanel id ="upPopupPnl" runat ="server" updatemode ="Conditional" xmlns:asp =#unknown">
< contenttemplate>
< asp:panel runat ="server" id ="pnlPopup" width ="300px" height ="300px" backcolor ="Azure">
style ="overflow:auto; border-color:Black; border-style:solid; border-width:2px;">
< asp:radiobuttonlist id ="rbl1" runat ="server">

< asp:button id ="btnPlacePopup" runat ="server" text ="Place" width ="100" height = "35" font-bold ="true">
OnClick ="btnPlacePopup_Click"/>
< asp:button id ="btnCancel" runat ="server" text ="Cancel" width ="100" height ="35" font-bold = "true">


< asp:button id ="btnDummy" runat ="server" text =不显示" style ="display:none;">
< ajaxtk:modalpopupextender id ="actPopup1" runat ="server" targetcontrolid ="btnDummy" backgroundcssclass ="modalBackground" xmlns:ajaxtk =#unknown">
PopupControlID ="pnlPopup" CancelControlID ="btnCancel">





Css类如下:-

.modalBackground
{
背景颜色:#B3B3CC;
透明度:0.5;
}


背后的代码:-

dim intHireEnquiryID为整数
受保护的Sub btnPlace_Click(ByVal发送者为对象,ByVal e为System.EventArgs)
intHireEnquiryID = CType(发送方,按钮).CommandArgument
Dim EXP作为新的例外
昏暗的参数(0)作为SqlParameter
params(0)=新的SqlParameter("@ intHireEnquiryID",intHireEnquiryID)
将Dim DS用作新数据集
DS = execQuery("spAgent_Get_Assigned_Workers",executeType.SPExecuteForDS,EXP,params)
如果DS.Tables(0).Rows.Count> 0然后
rbl1.DataSource = DS
rbl1.DataTextField ="WorkerDetail"
rbl1.DataValueField ="intWorkerID"
rbl1.DataBind()
如果结束
upPopupPnl.Update()
actPopup1.Show()
结束子


因此,它很好而且很好.
要记住的要点:-
但是请记住将modalpopupextender的TargetControlId从实际按钮删除为在页面上没有用的虚拟按钮,并将其隐藏.并且不要将必须显示的面板的可见属性设置为true或false.它将由ajaxmodalpopupextender自动处理.
实际上,为什么我将虚拟按钮用作modalpopup的targetcontrolid,是因为我需要部分回发页面以更新生成的单选按钮列表.但是,如果我们将主按钮作为targetcontrolid,则该按钮的默认行为将被modalpopup扩展程序覆盖,并且不会回发该页面.所以,我拿了一个虚拟按钮.在实际的按钮单击事件上,我生成列表并将其绑定到radiobuttonlist,然后调用更新面板的更新方法,然后调用modalpopup的show方法.

现在很好...
感谢所有试图帮助我的人.
非常感谢!
<gridview id="Grd" runat="server" autogeneratecolumns="false" cssclass="GridStyle">
HeaderStyle-Font-Size="Small" Width="960" Visible="false">
<columns>

''Columns goes here
<asp:templatefield headertext="Action" headerstyle-width="310px" itemstyle-horizontalalign="Left" xmlns:asp="#unknown">
<itemtemplate>
<asp:button id="btnDelete" runat="server" text="Delete" onclick="btnDelete_Click">
CommandArgument=''<%#Eval("intHireEnquiryID") %>'' />
<asp:button id="btnPlace" runat="server" text="Place" onclick="btnPlace_Click">
CommandArgument=''<%#Eval("intHireEnquiryID") %>'' />








Remove the modalpopupextender which was taken inside gridview and keep it in an update panel like below and remember remove the TargetControlId of modalpopupextender from actual button to a dummy button which has no use on the page and hide it. This btnDummy is only to remove the bug of raising error when targetcontrolid is not defined for modalpopup and nothing.


<asp:updatepanel id="upPopupPnl" runat="server" updatemode="Conditional" xmlns:asp="#unknown">
<contenttemplate>
<asp:panel runat="server" id="pnlPopup" width="300px" height="300px" backcolor="Azure">
style="overflow:auto;border-color:Black;border-style:solid;border-width:2px;">
<asp:radiobuttonlist id="rbl1" runat="server">

<asp:button id="btnPlacePopup" runat="server" text="Place" width="100" height="35" font-bold="true">
OnClick="btnPlacePopup_Click" />
<asp:button id="btnCancel" runat="server" text="Cancel" width="100" height="35" font-bold="true">


<asp:button id="btnDummy" runat="server" text="Not Display" style="display:none;">
<ajaxtk:modalpopupextender id="actPopup1" runat="server" targetcontrolid="btnDummy" backgroundcssclass="modalBackground" xmlns:ajaxtk="#unknown">
PopupControlID="pnlPopup" CancelControlID="btnCancel">





The Css class is as: -

.modalBackground
{
background-color:#B3B3CC;
opacity:0.5;
}


Code behind: -

dim intHireEnquiryIDas integer
Protected Sub btnPlace_Click(ByVal sender As Object, ByVal e As System.EventArgs)
intHireEnquiryID = CType(sender, Button).CommandArgument
Dim EXP As New Exception
Dim params(0) As SqlParameter
params(0) = New SqlParameter("@intHireEnquiryID", intHireEnquiryID)
Dim DS As New DataSet
DS = execQuery("spAgent_Get_Assigned_Workers", executionType.SPExecuteForDS, EXP, params)
If DS.Tables(0).Rows.Count > 0 Then
rbl1.DataSource = DS
rbl1.DataTextField = "WorkerDetail"
rbl1.DataValueField = "intWorkerID"
rbl1.DataBind()
End If
upPopupPnl.Update()
actPopup1.Show()
End Sub


Thus it works great and fine.
points to remember: -
But remember to remove the TargetControlId of modalpopupextender from actual button to a dummy button which has no use on the page and hide it. And do not set visible property of panel which has to show to true or false. It will handle automatically by ajaxmodalpopupextender.
Actually why i took a dummy button as targetcontrolid of modalpopup because i need to postback the page partially to update the generated list of radiobuttons. but if we take the main button as targetcontrolid then the default behaviour of button will be overridden by modalpopup extender and it will not postback the page. So, i took a dummy button. And on the actual button click event i generate the list and bind it to radiobuttonlist and then called the update method of update panel and then called the show method of modalpopup.

It''s fine now....
Thanks to all who tried to help me.
Thanks a lot!!


这篇关于AjaxModalPopupExtender会在首次单击后显示弹出窗口,但随后在随后的调用中将不触发按钮单击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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