Almommaimpacy
New Member
I have a confirm action Javascript popup box that is supposed to open when the user clicks an action button in a gridview. My problem is that the popup box doesn't open until after the entire sub's code has executed and the variable that needs to have a value assigned doesn't get the value assigned until it's too late. How can I get the popup to open and allow the user to populate the DelUserConfirm variable before the sub ends? Thanks in advance for the help! My code is as follows:Sub Gridview_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)\[code\] Dim currentcommand As String = e.CommandName Dim index As Integer = Convert.ToInt32(e.CommandArgument) Dim cell As GridViewRow = grdUsers.Rows(index) Dim currUserID As String = grdUsers.Rows(index).Cells(0).Text If e.CommandName = "DelUser" Then Dim DelUserConfirm As String = Request.Form("confirm_value") If (Not ClientScript.IsStartupScriptRegistered("alert")) Then Page.ClientScript.RegisterStartupScript(GetType(action), _ "alert", "Confirm()", True) End If If DelUserConfirm = "Yes" Then cmd.Connection = conn conn.Open() cmd.CommandText = "DELETE FROM USERS WHERE USER_NAME = '" + currUserID + "'" cmd.ExecuteNonQuery() conn.Close() dtUsers.Rows(index).Delete() grdUsers.DataSource = dtUsers grdUsers.DataBind() End If Exit Sub End If If e.CommandName = "EditUser" Then Session("EditUserPerms") = dtUsers(index) Session("UserPerms") = dtUserPerms Response.Redirect("AddEditUser.aspx") End IfEnd Sub\[/code\]Adding the webform code...\[code\]<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="UserAdmin.aspx.vb" Inherits="_3rd_party_data_reporting_tool.UserAdmin" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"><title></title></head><script type = "text/javascript">function Confirm() {var confirm_value = http://stackoverflow.com/questions/13771157/document.createElement("INPUT");confirm_value.type = "hidden";confirm_value.name = "confirm_value";if (confirm("Are you sure you want to Delete this user?")) {confirm_value.value = "http://stackoverflow.com/questions/13771157/Yes";} else {confirm_value.value = "http://stackoverflow.com/questions/13771157/No";}document.forms[0].appendChild(confirm_value);}</script><body><form id="UserAdmin" runat="server"><asp:Image ID="imgTRLogo" runat="server" Height="120px" ImageUrl="~/TR_Logo.bmp" Width="120px" style="z-index: 1; left: 5px; top: 5px; position: absolute" /><asp:Label ID="lblTitle1" runat="server" Text="CA - Global Product Operations" Font-Bold="True" Font-Names="Arial Black" Font-Size="XX-Large" style="z-index: 1; left: 170px; top: 20px; position: absolute"></asp:Label><asp:Label ID="lblTitle2" runat="server" Text="Productivity Tools" Font-Bold="True" Font-Names="Arial Black" Font-Size="XX-Large" style="z-index: 1; left: 282px; top: 60px; position: absolute"></asp:Label><asp:Label ID="lblTitle3" runat="server" Text="User Administration Panel" Font-Bold="True" Font-Names="Arial Black" Font-Size="Large" style="z-index: 1; left: 312px; top: 135px; position: absolute"></asp:Label><asp:GridView ID="grdUsers" runat="server" Font-Names="Arial" autogeneratecolumns="false" style="z-index: 1; left: 28px; top: 184px; position: absolute; height: 144px; width: 731px" OnRowCommand="Gridview_RowCommand" ><Columns><asp:BoundField DataField="USER_NAME" HeaderText="User ID"/><asp:BoundField DataField="PW" HeaderText="Password"/><asp:BoundField DataField="FIRST_NAME" HeaderText="First Name"/><asp:BoundField DataField="LAST_NAME" HeaderText="Last Name"/><asp:BoundField DataField="EMAIL" HeaderText="E-mail Address"/><asp:BoundField DataField="SAFE_ID" HeaderText="SAFE ID"/><asp:BoundField DataField="THIRDPTYRPT" HeaderText="3rd Party Report"/><asp:BoundField DataField="EDTK" HeaderText="eDTK Tool"/><asp:BoundField DataField="ADMIN" HeaderText="Admin"/><asp:buttonfield ButtonType="Button" CommandName="EditUser" HeaderText="Edit User?" Text="Edit" /><asp:buttonfield ButtonType="Button" CommandName="DelUser" HeaderText="Delete User?" Text="Delete" /></Columns></asp:GridView><asp:Button ID="cmdAddNewUser" runat="server" style="z-index: 1; left: 28px; top: 149px; position: absolute; width: 132px" Text="Add New User" /><asp:Button ID="cmdExit" runat="server" style="position: absolute; top: 22px; left: 729px; height: 45px; width: 54px" Text="Exit" /></form></body></html>\[/code\]