当我选中gridview auto中的复选框时,如何关闭弹出窗口 [英] How I can close the popup window when I checked the checkbox in gridview auto

查看:106
本文介绍了当我选中gridview auto中的复选框时,如何关闭弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个弹出名称(地址),在此网格复选框的弹出网格视图中,我想在此网格中选中一行以关闭此弹出窗口并将第(2)列中的文本放入文本中另一个页面名称的盒子(员工)



我怎么做...

i没有错误但是这个代码呢不工作



我尝试过:



受保护的子checkcuntry_CheckedChanged(ByVal sender As Object,ByVal e As System.EventArgs)

For i = 0 To GridView1.Rows.Count - 2

If CType(GridView1.Rows(i) ).FindControl(checkcuntry),CheckBox).Checked = True然后

会话(地址)= CType(GridView1.Rows(i).FindControl(Label4),Label)。文字

Me.close()

Response.Redirect(Employee.aspx)

退出Sub

否则

MsgBox(不能关闭这个页面)

结束如果

下一页

结束Sub

I have a popup name(address) and in this popup gridview in this grid checkbox ,I wanna when I checked one row in this grid to close this popup auto and take the text in column(2) to put it in text box in another page name (employee)

how i can do it ...
i don"t have an error but this code it doesn't work

What I have tried:

Protected Sub checkcuntry_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)
For i = 0 To GridView1.Rows.Count - 2
If CType(GridView1.Rows(i).FindControl("checkcuntry"), CheckBox).Checked = True Then
Session("address") = CType(GridView1.Rows(i).FindControl("Label4"), Label).Text
Me.close()
Response.Redirect("Employee.aspx")
Exit Sub
Else
MsgBox("can't close this page ")
End If
Next
End Sub

推荐答案

现在我通过您显示的代码片段看到了你的意思。



直接的问题就像那样微不足道:你设法不定义 fnOpen 并在调用此函数时使其可见。没有什么可以帮助的;你没有显示相应的代码上下文,但这是基本的编程问题,无论如何你必须解决,否则你根本不能做任何编程。



问题弹出更难。当然, Window.showModalDialog 可以正常工作。但首先要注意:它已被弃用: Window.showModalDialog() - Web API | MDN [ ^ ]。



实际上,你不应该使用它;从浏览器兼容性的角度来看,这将是不好的做法。



现在,关闭窗口可以从当前文档的JavaScript或其他文档完成。对于当前文档,它与此 window.close()一样简单。您也可以关闭其他窗口,但是您必须具有该窗口对象的引用(例如,此引用由 window.open 返回: Window.open() - Web API | MDN [ ^ ])。



现在,最糟糕的是:并非总是可能。如果窗口是选项卡式浏览器的选项卡,则您无法将其关闭。你无能为力。如果窗口显示为模态,则没有这样的问题,但您可以在同一页面上关闭它;你在父窗口中没有可以关闭它的任何正在运行的代码,因为它很好......模态。



这是一个想法:它是最好避免 Window.showModalDialog window.open 。浏览器将这两种情况作为弹出窗口处理,在客户端可选择但非常典型地阻止它们。



更多细节,请参阅我的文章从零开始的模态弹出窗口 [ ^ ]。



它解释了莫代尔的流行概念弹出窗口模拟同一网页上的某些模态行为。这种方法不仅绕过阻止,因为没有创建任何浏览器窗口或选项卡。您不需要使用我的从头开始代码;有许多可用的解决方案,具有大量的效果,首先是调光(我实现),还有许多其他的,例如动画过渡效果:

对话| jQuery UI [ ^ ],

< a href =http://bfy.tw/2Zky> JavaScript模式弹出窗口 [ ^ ]。



-SA
Now I see what you mean, by the code fragment you've shown.

The immediate "problem" is as trivial as that: you managed not to define fnOpen and make it visible at the point you call this function. There is nothing to help with; you did not show the appropriate code context, but this is elementary programming issue you have to sort out anyway, otherwise you cannot do any programming at all.

The problem with popup is more difficult. Certainly, Window.showModalDialog can work. But first of all, pay attention: it is deprecated: Window.showModalDialog() — Web APIs | MDN[^].

Practically, you should not use it; it would be the bad practice, from the browser compatibility standpoint.

Now, closing a window can be done from the JavaScript of the current document or from the other document. For a current document, it as trivial as this window.close(). You can close some other window as well, but you have to have the reference of that window object (such reference is, for example, returned by window.open: Window.open() — Web APIs | MDN[^]).

Now, the worst thing is: it is not always possible. If the 'window' is a tab of the tabbed browser, you cannot close it. There is nothing you can do. And if the window is shown as modal, there is no such problem, but you can close it on the same page; you don't have any running code in the parent window which could close it, because it is, well… modal.

Here is the idea: it's the best to avoid both Window.showModalDialog and window.open. The browser will handle both cases as "pop-up window", which will be, optionally but very typically, blocked on the client-side.

For some more detail, please see my article Modal Popup From Scratch[^].

It explains the popular concept of "modal popup" which simulates some modal behavior on the same Web page. Not only this approach bypass the blocking, because there are not any browser windows or tabs created. You don't need to use my "from scratch" code; there are many available solutions, featuring a good number of effects, first of all, dimming (which I implement), but also many other, such as animated transition effects:
Dialog | jQuery UI[^],
JavaScript modal popup[^].

—SA


这篇关于当我选中gridview auto中的复选框时,如何关闭弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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