Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Focus on Popup message

Status
Not open for further replies.

rnooraei

Programmer
Apr 5, 2005
74
CA
Hi
I have the following code to get confirmation, before deleting a row. My problem is the popup window not always get focus which means it already open but user can not see it (it is going behind the current window). How could I fix this problem? Any help appreciated.
Thanks

Protected Sub grdContacts_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles grdContacts.RowDeleting
Dim result As Integer
result = MsgBox("Are you sure you want to delete tis record?", MsgBoxStyle.OkCancel, "Warning")
If result = 2 Then
e.Cancel = True
End If
End Sub
 
is this a windows or web app. msgbox will not work for a web app.. it will show on the server, not the client pc.
 
It is web application. I don't know how to use javascript in this code.
 
Code:
<script type=text/javascript>	
var answer = confirm("Are you sure you want to delete this record?")
	if (answer){
		//delete record
	}
	else{
		//cancel here
	}
</script>
 
that's as far as i can get you...you may want to look at the RegisterStartupScript to help you to intertwine the javascript and .net code
 
Or if the user confirms the delete you can use the loation.href code with some query strings like this

Code:
location.href='yourpagename?RunDelete=True&IDToDelete=45'
[code]

Then put an if statement in your page load to see if these query string variables have values. 

This may not be the best solution but it is one.
 
I try to use this and nothing happen

Dim popupScript As String = "<script language='javascript'>" & _
"window.open('PopUp.aspx', 'CustomPopUp', " & _
"'width=200, height=200, menubar=yes, resizable=no')" & _
"</script>"

Page.RegisterStartupScript("PopupScript", popupScript)

it is complaing about Page.RegisterStartupScript
 
Try calling this javascript function when the user goes to delete

Code:
<script type=text/javascript>  
function ConfirmDelete()
{
var answer = confirm("Are you sure you want to delete this record?")
    if (answer)
    {
        location.href='yourpagename?RunDelete=True&IDToDelete=45'
    }
}
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top