Hi All,
I have a web page, this page has two display form methods. One is to display
a confirm delete and the
other to display a message when the record is deleted.
The problem is that when I choose Yes on the page to confirm delete only
part of the second page is display
and not all the page.
What could be the problem? Here is my code....
<%
'************************************************************
' Purpose: Organization Insert/Update page
'************************************************************
OPTION EXPLICIT
'********
'Includes
'********
%>
<!--- #include file="..\gen_functions.asp" --->
<%
'*********
'Constants
'*********
const adInteger = 3
const adCmdStoredProc = &H0004
'*****************
'Private Variables
'*****************
dim conn
dim command
dim rs
dim strFlow
'*****************************************
'Session Variables Referenced In This File
' session("OrganizationID")
'*****************************************
'***************
'Open connection
'***************
sub OpenDB
'Instantiate obj vars
set conn = Server.CreateObject("ADODB.Connection")
set command = Server.CreateObject("ADODB.Command")
set rs = Server.CreateObject("ADODB.RecordSet")
'Open DB
'conn.Open "advertisementDB"
conn.Open "Provider=SQLOLEDB;Data Source=ROBERTODELL;Initial
Catalog=Advertisement;User ID=sa"
end sub
'*******************************
'Setup Specific Stored Procedure
'*******************************
sub SetupProcedure(com, strProcName)
'Setup procedure
com.ActiveConnection = conn
com.CommandType = adCmdStoredProc
com.CommandText = strProcName
com.Parameters.Refresh
end sub
'********
'GetField
'********
function GetField( FieldName )
on error resume next
'Prevent exception 'Invalid Use of Null 'Marcio 08/07/2003 11:30 PM
if IsNull(rs(FieldName)) or IsEmpty(rs(FieldName)) then
GetField = CStr("")
else
GetField = rs( FieldName )
end if
'If error, return it
if err.number <> 0 then
strMessage = "* " & err.Description
strFlow = "Error"
GetField = ""
end if
end function
'******
'Delete
'******
sub Delete
on error resume next
'Optional parameters (do not fill out optional parameters, procedure will
make it NULL)
if request.form("hdnOrganizationID") <> "" then
command.Parameters("@OrganizationID") =
request.form("hdnOrganizationID")
end if
if session("OrganizationID") > 0 then
command.Parameters("@OrganizationID") = session("OrganizationID") 'Will
be null when inserting
end if
'Execute command... be ready to display exceptions generated by DB
command.Execute
'If an error happened in DB
if err.Number <> 0 then
strFlow = "Error" 'This will force form to load previous values
strMessage = "* " & err.Description
'No errors in DB
else
'If save and new, reset client id and reload form
if strFlow = "Delete" then
session("OrganizationID") = 0
end if
'Display form and message... successfully updated
strMessage = "Organization successfully deleted."
end if
'Always display the form. GetField() and GetLookup() will know from where
to populate
DisplayFormAfterDelete
end sub
'*****************
'PopulateForDelete
'*****************
sub PopulateForDelete
on error resume next
'Fill parameters and Execute command
command.Parameters("@OrganizationID") = session("OrganizationID")
'Execute command... be ready to display exceptions generated by DB
set rs = command.Execute
'If an error happened in DB
if err.number <> 0 then
strFlow = "Error" 'This will force form to load previous values
response.write "<center><br><font color='red'>" & err.Description &
"</font></center>"
end if
end sub
'****************
'Close Connectoin
'****************
sub CloseDB
'Close DB when state is not adStateClosed
if rs.State <> 0 then rs.Close
if command.State <> 0 then command.Close
if conn.State <> 0 then conn.Close
'Release mem
set rs = nothing
set command = nothing
set conn = nothing
end sub
'************
'Display Form
'************
sub DisplayForm
%>
<html>
<head>
<title>Advertisement System - Delete Organizations</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<script language="javascript">
// T r i m ! ! !
function trim( inputString )
{
// Removes leading and trailing spaces from the passed string. Also
removes
// consecutive spaces and replaces it with one space. If something
besides
// a string is passed in (null, custom object, etc.) then return the
input.
if( typeof inputString != "string")
return inputString;
// Vars
var retValue = inputString;
var ch = retValue.substring(0, 1);
// Check for spaces at the beginning of the string
while( ch == " " )
{
retValue = retValue.substring( 1 , retValue.length );
ch = retValue.substring( 0 , 1 );
}
// Check for spaces at the end of the string
ch = retValue.substring( retValue.length - 1, retValue.length );
while( ch == " " )
{
retValue = retValue.substring(0, retValue.length-1);
ch = retValue.substring(retValue.length-1, retValue.length);
}
// Note that there are two spaces in the string - look for multiple
spaces within the string
while( retValue.indexOf(" ") != -1 )
// Again, there are two spaces in each of the strings
retValue = retValue.substring(0, retValue.indexOf(" ")) +
retValue.substring(retValue.indexOf(" ")+1, retValue.length);
// Return the trimmed string back to the user
return retValue;
}
// Performs validation and submits the form
function Validate( action )
{
if (action == 'No')
{
// Ready to submit
Organization.hdnFlow.value = action;
Organization.submit();
return;
}
// Ready to submit
Organization.hdnFlow.value = action;
Organization.submit();
}
</script>
<body bgcolor="#FFFFFF" text="#000000">
<center>
<table width="800" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="800" height="23" valign="top"> <table width="100%"
border="0" cellpadding="0" cellspacing="0" style="font-family: Verdana,
Geneva, Arial, Helvetica, sans-serif; font-size: x-small; color: Black;">
<tr>
<td width="21" height="23"></td>
<td style="font-weight: bolder; font-size: small; font-variant:
small-caps; ">
Welcome <%= session("AdminName") %>! </td>
<td width="461"></td>
<td width="93" valign="top"> <div align="right"><font
face="Arial, Helvetica, sans-serif"><b><font size="3"><a
href="..\login.asp"><font
size="2">LogOut</font></a></font></b></font></div></td>
<td width="22"></td>
</tr>
</table></td>
</tr>
</table>
<br>
<!--- #include virtual= "/advertisement/admin/menu.html" --->
<form id="Organization" method="post" action="Organization_D.asp"
name="Organization">
<table align="rigth" width="100%" border="0" cellpadding="1"
cellspacing="1" halign="right" style="font-family: Verdana, Geneva, Arial,
Helvetica, sans-serif; font-size: xx-small;">
<!--DWLayoutTable-->
<tr>
<td width="89" height="15"></td>
<td width="204"></td>
<td width="369"></td>
<td width="83"></td>
</tr>
<tr>
<td height="25"></td>
<td align="right" valign="center"> <font face="Arial, Helvetica,
sans-serif" size="2" color="red">*</font>
Name</td>
<td valign="middle"><%= GetField("Name")%> </td>
<td></td>
</tr>
<tr>
<td height="23"></td>
<td align="right" valign="center">Activity</td>
<td valign="middle"><%= GetField("Activity")%></td>
<td></td>
</tr>
<tr>
<td height="23"></td>
<td align="right" valign="middle">Contact First Name</td>
<td valign="middle"><%= GetField("FirstName")%></td>
<td></td>
</tr>
<tr>
<td height="23"></td>
<td align="right" valign="middle">Contact Last Name</td>
<td valign="middle"><%= GetField("LastName")%> </td>
<td></td>
</tr>
<tr>
<td height="23"></td>
<td align="right" valign="middle">Contact Email</td>
<td valign="middle"><%= GetField("Email")%></td>
<td></td>
</tr>
<tr>
<td height="34"></td>
<td> </td>
<td></td>
<td></td>
</tr>
<tr>
<td height="45"></td>
<td colspan="2" align="center" valign="middle" > <input
name="hdnFlow" type="hidden" id="hdnFlow2">
<input type="hidden" name="hdnOrganizationID" >
Are you sure you want to delete this record? <br>
<input name="btnYes" type="button" style="cursor:hand"
onClick="Validate('Yes')" value="Yes">
<input type="button" name="btnNo" onClick="Validate('No')"
value="No" style="cursor:hand" >
</td>
<td> </td>
</tr>
<tr>
<td height="24"></td>
<td> </td>
<td></td>
<td></td>
</tr>
</table>
</form>
<!--- #include virtual= "/advertisement/admin/menu.html" --->
</center>
</body>
</html>
<%
end sub
sub DisplayFormAfterDelete
%>
<html>
<head>
<title>Advertisement System - Deleted</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<center>
<script language="JavaScript">
// Performs validation and submits the form
function validate( action )
{
if (action == 'No')
{
// Ready to submit
Organization.hdnFlow.value = action;
Organization.submit();
return;
}
}
</script>
<br>
<table width="778" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="778" height="40" valign="top"> <table width="100%"
border="0" cellpadding="0" cellspacing="0" style="font-family: Verdana,
Geneva, Arial, Helvetica, sans-serif; font-size: x-small; color: Black;">
<!--DWLayoutTable-->
<tr>
<td width="21" height="36"></td>
<td width="236" valign="top" style="font-weight: bolder;
font-size: small; font-variant: small-caps; ">
Welcome <%= session("AdminName") %>! </td>
<td width="313" align="left" valign="middle" id="msgMessage"
style="font-weight: normal; font-size: xx-small;color: red; font-family:
verdana,tahoma,monospace; ">
<%= strMessage%> </td>
<td width="208" valign="top"> <div align="right"><font
face="Arial, Helvetica, sans-serif"><b><font size="3"><a
href="..\login.asp"><font size="2">
LogOut</font></a></font></b></font></div></td>
</tr>
<tr>
<td height="4"></td>
<td></td>
<td></td>
<td></td>
</tr>
</table></td>
</tr>
</table>
<!--- #include virtual= "/advertisement/admin/menu.html" --->
<form id="Organization" method="post" action="Organization_D.asp"
name="Organization">
<br>
<font style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: xx-small;">Go to Organization Browser </font>
<br>
<br>
<input name="btnGo" type="button" onclick="validate('No')"
style="border-bottom-style: groove; border-bottom-width: thin;
border-left-style: groove; border-left-width: thin; border-top-style:
groove; border-top-width: thin; border-right-style: groove;
border-right-width: thin; cursor:hand; background-color: #ADD8E6;"
value="Go">
<input type="hidden" name="hdnFlow" >
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</form>
<!--- #include virtual= "/advertisement/admin/menu.html" --->
</center>
</body>
</html>
<%
end sub
'*******
'M A I N
'*******
'Verify if login is not expired
CheckLoginSession
'Get the flow information from hidden field
if request.form( "hdnFlow" ) <> "" then
strFlow = request.form( "hdnFlow" )
else
strFlow = "Confirm"
end if
'Get the affiliateid from querystring
if request.querystring( "id" ) <> "" then
session( "OrganizationID" ) = CInt(request.querystring( "id" ))
'strFlow = "Confirm"
end if
'****************************************************
'Understand the navigation flow controlled by strFlow
'
' "Delete : Blank form - GetField returns blanks. Thus, load form with
blanks
' "Error" : Will populate form like in "Delete", based in response.form()
'
'****************************************************
select case strFlow
'Yes
case "Yes", "Delete"
OpenDB
SetupProcedure command, "dOrganization"
Delete
CloseDB
' Error or Update
case "Confirm", "Error"
OpenDB
'If delete, populate form to confirm
if strFlow = "Confirm" then
SetupProcedure command, "sOrganization"
PopulateForDelete
end if
DisplayForm
CloseDB
' When user choose No, it backs to the Affiliate browser
case "No"
response.redirect"brw.asp?sbj=Organization"
end select
%>
Thanks in advance
Roberto