在Oncommand事件中调用时,模式弹出窗口加载两次 [英] Modal popup loads twice when calling in Oncommand event

查看:61
本文介绍了在Oncommand事件中调用时,模式弹出窗口加载两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好


我有模式弹出窗口,可以使用Imagebutton在网格内部调用.
在服务器端事件imgView_OnCommand中调用该弹出窗口.但我两次弹出窗口.

 <   asp:TemplateField     HeaderText   ="     ItemStyle-Width   ="  12%"  HeaderStyle-Width   ="  > 
                                    <   ItemTemplate  > 
                                        <   asp:ImageButton     ID   ="   runat   服务器"  ImageUrl   〜/Images/delete1.jpg" 宽度  ="  
 
                                                                           高度  ="     OnClick   ="     OnCommand   ="     CommandArgument   ='  <% #Eval(" )% > ' 
 
                                                                            CommandName   ="    / > 
                                    <  /ItemTemplate  > 
                                    <   HeaderStyle     ="   Center" / <  /asp:TemplateField  >  




问候
froxy

解决方案

您将事件触发两次.
网格使用CommandName触发其OnItemCommand事件,而ImageButton也触发onClick处理程序,因此,如果两个事件都执行相同的代码,则将弹出两次.

没有这样的事件:imgView_OnCommand.

您称之为事件"的事实可能是您困惑的根源.

难怪你否认自己开除了两次,但事实表明你做了两次.也许,这不是触发事件写操作,而是两次调用事件 handler .解决起来相对容易:在处理程序的主体内放置一个断点,在调试器下运行并检查调用堆栈.您将看到冗余呼叫来自何处.

—SA


Hi All


I have modal popup which is called inside the grid using Imagebutton.
The popup is called in the server side event imgView_OnCommand. but i get the popup twice.

<asp:TemplateField HeaderText="Delete" ItemStyle-Width="12%" HeaderStyle-Width="12%">
                                    <ItemTemplate>
                                        <asp:ImageButton ID="imgDelete" runat="server" ImageUrl="~/Images/delete1.jpg" Width="20px"

                                            Height="20px" OnClick="imgDelete_Click" OnCommand="imgDelete_Command" CommandArgument='<%# Eval("UserId") %>'

                                            CommandName="DeleteUser" />
                                    </ItemTemplate>
                                    <HeaderStyle HorizontalAlign="Center" />
                                </asp:TemplateField>




regards
froxy

解决方案

You are firing the event twice.
The CommandName is being used by the grid to fire it''s OnItemCommand event, while your ImageButton is firing the onClick handler as well, so if the same code is being executed for both events then you would get your popup twice.


There is no such event: imgView_OnCommand.

The fact you call this "event" is maybe the source of your confusion.

No wonder you deny you fire twice, but the facts show you do something twice. Maybe, this is not firing the event write but calling an event handler twice. It''s relatively easy to resolve: put a break point inside the handler''s body, run under debugger and examine the call stack. You will see where the redundant call came from.

—SA


这篇关于在Oncommand事件中调用时,模式弹出窗口加载两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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