debbie_lee104
07-19-2007, 03:56 PM
Hi i'm trying to create an alert box. I dont want to execute a javascript at a button pression, but only if a condition is true. This is my aspx.vb file:
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
'-----------------------------------------------------------------------
'Description: This function executes when the Cancel button is clicked on. It cancels
' the pending file(s) that are currently checked.
'
'Inputs: System Controlled
'
'Ouputs: None
'
'Return Code: None
'-----------------------------------------------------------------------
Dim MyTable As HtmlTable = Page.FindControl("tabJobList")
Dim MyRows As HtmlTableRow
Dim MyCheckBox As HtmlInputCheckBox
Dim Cnt As Integer
Dim JobID As Integer
Dim CancelSuccess As Boolean = False
Dim OutParms As DictionaryEntry
Dim MyDR As SqlClient.SqlDataReader 'declare sql server connection
Dim CancelQuery As New PCMS_Services.DatabaseAccess
Dim MyLog As PCMS_Services.Log = New PCMS_Services.Log
Try
For Cnt = 1 To MyTable.Rows.Count - 1
MyRows = MyTable.Rows(Cnt)
If MyRows.Cells(0).Controls.Item(0).ID <> Nothing Then
MyCheckBox = MyRows.Cells(0).Controls(0)
If MyCheckBox.Checked = True Then
JobID = MyRows.Cells(1).InnerText()
'**************************************************
' Ensure we have an open connection to the database. Pass in the name of the
' database this user is currently accessing to the query.
' Make connection to the global database and if the query is successful,
' cancel job from job list
'**************************************************
CancelQuery = New PCMS_Services.DatabaseAccess
CancelQuery.Open(Session("DB_UserName"), Session("DB_Password"), Session("DB_ActServer"), Session("DB_Actuals"))
CancelQuery.ClearParms()
CancelQuery.AddParameter("@InJob", JobID, ParameterDirection.Input, SqlDbType.Int, 4)
CancelQuery.AddParameter("@InUser", Session("LoggedOnUser"))
CancelQuery.AddParameter("@RetCount", -1, ParameterDirection.Output, SqlDbType.Int, 4)
MyDR = CancelQuery.ExecuteCommand("[dbo.ADW_CancelPendingJobs",PCMS_Services.DatabaseAccess.ExecuteType.Reader, CommandType.StoredProcedure)
'**************************************************
' If stored procedure returns <> 1 , notify user that the job is Active and cannot be cancelled
'**************************************************
If MyDR.RecordsAffected = 1 Then '1 indicates failure to cancel
MsgBox("This job is Active and cannot be cancelled")//error message here
End If
End If
End If
Next
Catch ex As Exception
MyLog.WriteEvent("Unable to cancel pending jobs. " & ex.StackTrace & ex.Message)
Throw
Finally
If Not MyDR Is Nothing Then
MyDR.Close()
MyDR = Nothing
End If
If Not CancelQuery Is Nothing Then
CancelQuery.CloseConnection()
CancelQuery.Dispose()
CancelQuery = Nothing
End If
End Try
Response.Redirect("../PCMS_WebPages/ActualsCurJob.aspx")
End Sub
I'm getting the following error: "It is invalid to show a modal dialog or form when the application is not running in UserInteractive mode. Specify the service or DefaultDesktopOnly style to display a notification from a service application"
Needless to say that i'm working with a modaldialog box and when a user is cancelling a job that has a return value=1, i want the alert box to show that the job cannot be cancelled.
I'm also working with an ASP file where a table is dynamically created inside the modaldialog box:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="ActualsCurJob.aspx.vb" Inherits="PCMS.ActualsCurJob"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Current Job Status</title>
<base target="_self">
<%
' =================================================================================================
' Name: ActualsCurJob.aspx
'
' Description: This is an modal window that list the active and pending ADW Extract jobs
'
' Inputs: None
'
' Outputs: None
'
' Return Codes: None
'
' Objects Included: None
' =========================================================
=========================================================
%>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<LINK href="PCMS_Web.css" rel="stylesheet">
<script language="javascript">
function Disable()
{
//*********************************************************************************
//Description: Enable/Disable Cancel File button depending on whether a file is
// checked
//
//Input: None
//
//Output: None
//
//Return Code: None
//*********************************************************************************
var ID;
var frm = document.forms[1];
var xx = document.getElementById("tabJobList");
var icnt = xx.rows;
//var MyCookie = "";
//xxx=yyy;
for (var fileID=2; fileID <= icnt.length; fileID++)
{
ID = document.getElementById(fileID);
if(ID != null)
{
if(ID.checked)
{
document.forms("frmCurJobs").btnCancel.disabled = false;
break;
//MyCookie = MyCookie + ",";
}
else
{
document.forms("frmCurJobs").btnCancel.disabled = true;
}
}
}
}
function ShowMessage()
{
alert("This job is Active and cannot be cancelled");
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="frmCurJobs" method="post" runat="server">
<TABLE height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0">
<TR height="29">
<TD style="HEIGHT: 29px" width="11"> </TD> <!--chasm between nav and tabs-->
<TD style="HEIGHT: 29px" vAlign="top" align="left">
<TABLE cellSpacing="0" cellPadding="0" border="0">
<TR>
<td><br>
<br>
</td>
</TR>
<TR>
<TD colSpan="5">
<% ' START OF HEADER %>
<TABLE cellSpacing="0" cellPadding="0" width="100%" bgColor="#330099" border="0">
<TR vAlign="bottom">
<% ' Start of the buttons %>
<TD vAlign="top" align="left">
<asp:button id="btnCancel" enabled="False" Text="Cancel Job" runat="server"></asp:button>
<asp:button id="btnRefresh" runat="server" Text="Refresh List"></asp:button>
</TD>
</TR>
</TABLE>
<% ' END OF HEADER %>
</TD>
</TR>
<TR>
<td></td>
<td colSpan="4">
</td>
</TR>
<tr>
<TD align="center" colSpan="5"><asp:panel id="pnlNoFiles" Runat="server" Visible="False"><STRONG><FONT color="red">No
Scheduled Jobs found.</FONT></STRONG>
</asp:panel><BR>
</TD>
</tr>
<TR>
<td></td>
<TD colSpan="4"><asp:panel id="pnlFileList" Runat="server" Visible="True">
<TABLE id="tabJobList" cellSpacing="0" cellPadding="0" width="100%" border="1" runat="server">
</TABLE>
</asp:panel></TD>
</TR>
<TR>
<td colSpan="5">
<hr SIZE="5">
</td>
</TR>
<tr>
<td></td>
<TD colSpan="4"><BR>
<!-- #INCLUDE file="../common/Footer.asp" --></TD>
</tr>
</TABLE>
</TD>
</TR>
</TABLE>
<INPUT id="PlnErrorMsg" type="hidden" name="PlnErrorMsg" runat="server"> <INPUT id="PlnErrorShow" type="hidden" name="PlnErrorShow" runat="server">
</form>
</body>
</HTML>
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
'-----------------------------------------------------------------------
'Description: This function executes when the Cancel button is clicked on. It cancels
' the pending file(s) that are currently checked.
'
'Inputs: System Controlled
'
'Ouputs: None
'
'Return Code: None
'-----------------------------------------------------------------------
Dim MyTable As HtmlTable = Page.FindControl("tabJobList")
Dim MyRows As HtmlTableRow
Dim MyCheckBox As HtmlInputCheckBox
Dim Cnt As Integer
Dim JobID As Integer
Dim CancelSuccess As Boolean = False
Dim OutParms As DictionaryEntry
Dim MyDR As SqlClient.SqlDataReader 'declare sql server connection
Dim CancelQuery As New PCMS_Services.DatabaseAccess
Dim MyLog As PCMS_Services.Log = New PCMS_Services.Log
Try
For Cnt = 1 To MyTable.Rows.Count - 1
MyRows = MyTable.Rows(Cnt)
If MyRows.Cells(0).Controls.Item(0).ID <> Nothing Then
MyCheckBox = MyRows.Cells(0).Controls(0)
If MyCheckBox.Checked = True Then
JobID = MyRows.Cells(1).InnerText()
'**************************************************
' Ensure we have an open connection to the database. Pass in the name of the
' database this user is currently accessing to the query.
' Make connection to the global database and if the query is successful,
' cancel job from job list
'**************************************************
CancelQuery = New PCMS_Services.DatabaseAccess
CancelQuery.Open(Session("DB_UserName"), Session("DB_Password"), Session("DB_ActServer"), Session("DB_Actuals"))
CancelQuery.ClearParms()
CancelQuery.AddParameter("@InJob", JobID, ParameterDirection.Input, SqlDbType.Int, 4)
CancelQuery.AddParameter("@InUser", Session("LoggedOnUser"))
CancelQuery.AddParameter("@RetCount", -1, ParameterDirection.Output, SqlDbType.Int, 4)
MyDR = CancelQuery.ExecuteCommand("[dbo.ADW_CancelPendingJobs",PCMS_Services.DatabaseAccess.ExecuteType.Reader, CommandType.StoredProcedure)
'**************************************************
' If stored procedure returns <> 1 , notify user that the job is Active and cannot be cancelled
'**************************************************
If MyDR.RecordsAffected = 1 Then '1 indicates failure to cancel
MsgBox("This job is Active and cannot be cancelled")//error message here
End If
End If
End If
Next
Catch ex As Exception
MyLog.WriteEvent("Unable to cancel pending jobs. " & ex.StackTrace & ex.Message)
Throw
Finally
If Not MyDR Is Nothing Then
MyDR.Close()
MyDR = Nothing
End If
If Not CancelQuery Is Nothing Then
CancelQuery.CloseConnection()
CancelQuery.Dispose()
CancelQuery = Nothing
End If
End Try
Response.Redirect("../PCMS_WebPages/ActualsCurJob.aspx")
End Sub
I'm getting the following error: "It is invalid to show a modal dialog or form when the application is not running in UserInteractive mode. Specify the service or DefaultDesktopOnly style to display a notification from a service application"
Needless to say that i'm working with a modaldialog box and when a user is cancelling a job that has a return value=1, i want the alert box to show that the job cannot be cancelled.
I'm also working with an ASP file where a table is dynamically created inside the modaldialog box:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="ActualsCurJob.aspx.vb" Inherits="PCMS.ActualsCurJob"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Current Job Status</title>
<base target="_self">
<%
' =================================================================================================
' Name: ActualsCurJob.aspx
'
' Description: This is an modal window that list the active and pending ADW Extract jobs
'
' Inputs: None
'
' Outputs: None
'
' Return Codes: None
'
' Objects Included: None
' =========================================================
=========================================================
%>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<LINK href="PCMS_Web.css" rel="stylesheet">
<script language="javascript">
function Disable()
{
//*********************************************************************************
//Description: Enable/Disable Cancel File button depending on whether a file is
// checked
//
//Input: None
//
//Output: None
//
//Return Code: None
//*********************************************************************************
var ID;
var frm = document.forms[1];
var xx = document.getElementById("tabJobList");
var icnt = xx.rows;
//var MyCookie = "";
//xxx=yyy;
for (var fileID=2; fileID <= icnt.length; fileID++)
{
ID = document.getElementById(fileID);
if(ID != null)
{
if(ID.checked)
{
document.forms("frmCurJobs").btnCancel.disabled = false;
break;
//MyCookie = MyCookie + ",";
}
else
{
document.forms("frmCurJobs").btnCancel.disabled = true;
}
}
}
}
function ShowMessage()
{
alert("This job is Active and cannot be cancelled");
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="frmCurJobs" method="post" runat="server">
<TABLE height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0">
<TR height="29">
<TD style="HEIGHT: 29px" width="11"> </TD> <!--chasm between nav and tabs-->
<TD style="HEIGHT: 29px" vAlign="top" align="left">
<TABLE cellSpacing="0" cellPadding="0" border="0">
<TR>
<td><br>
<br>
</td>
</TR>
<TR>
<TD colSpan="5">
<% ' START OF HEADER %>
<TABLE cellSpacing="0" cellPadding="0" width="100%" bgColor="#330099" border="0">
<TR vAlign="bottom">
<% ' Start of the buttons %>
<TD vAlign="top" align="left">
<asp:button id="btnCancel" enabled="False" Text="Cancel Job" runat="server"></asp:button>
<asp:button id="btnRefresh" runat="server" Text="Refresh List"></asp:button>
</TD>
</TR>
</TABLE>
<% ' END OF HEADER %>
</TD>
</TR>
<TR>
<td></td>
<td colSpan="4">
</td>
</TR>
<tr>
<TD align="center" colSpan="5"><asp:panel id="pnlNoFiles" Runat="server" Visible="False"><STRONG><FONT color="red">No
Scheduled Jobs found.</FONT></STRONG>
</asp:panel><BR>
</TD>
</tr>
<TR>
<td></td>
<TD colSpan="4"><asp:panel id="pnlFileList" Runat="server" Visible="True">
<TABLE id="tabJobList" cellSpacing="0" cellPadding="0" width="100%" border="1" runat="server">
</TABLE>
</asp:panel></TD>
</TR>
<TR>
<td colSpan="5">
<hr SIZE="5">
</td>
</TR>
<tr>
<td></td>
<TD colSpan="4"><BR>
<!-- #INCLUDE file="../common/Footer.asp" --></TD>
</tr>
</TABLE>
</TD>
</TR>
</TABLE>
<INPUT id="PlnErrorMsg" type="hidden" name="PlnErrorMsg" runat="server"> <INPUT id="PlnErrorShow" type="hidden" name="PlnErrorShow" runat="server">
</form>
</body>
</HTML>