Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 23-May-16 1:55am
Comments
Sergey Alexandrovich Kryukov 22-May-16 10:41am    
Is it ASP.NET? If this is a Web application, the best solution would be not using any pop-up windows. It's not always possible to close a pop-up window; and in cases you can do it, the users will likely find it too intrusive.
—SA
Malak Hudaib 23-May-16 7:14am    
thanks for reply ...
i changed the popup and use the showModalDialog
and call the name of function in
the button onclick="fnOpen"

but i have this error
Error 8 'fnOpen' is not a member of 'ASP.employee_aspx'.


<script>
function fnOpen() {
var x = window.showModalDialog("Address.aspx", '', "location=0,resizable=0,ScrollBars=1,statusbar=1,width=400,height=300,left=20,top=10,moveable=0");
}
</script>

1 solution

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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900