<%
Response.Buffer = EW_RESPONSE_BUFFER
%>
<!--#include file="ewcfg7.asp"-->
<!--#include file="xwfbinfo.asp"-->
<!--#include file="bhlminfo.asp"-->
<!--#include file="xwlminfo.asp"-->
<!--#include file="zlogininfo.asp"-->
<!--#include file="sjlminfo.asp"-->
<!--#include file="aspfn7.asp"-->
<!--#include file="userfn7.asp"-->
<% Session.Timeout = 900 %>
<%
Response.Expires = 0
Response.ExpiresAbsolute = Now() - 1
Response.AddHeader "pragma", "no-cache"
Response.AddHeader "cache-control", "private, no-cache, no-store, must-revalidate"
%>
<%

' Define page object
Dim xwfb_edit
Set xwfb_edit = New cxwfb_edit
Set Page = xwfb_edit

' Page init processing
Call xwfb_edit.Page_Init()

' Page main processing
Call xwfb_edit.Page_Main()
%>
<!--#include file="header.asp"-->
<script type="text/javascript">
<!--
// Create page object
var xwfb_edit = new ew_Page("xwfb_edit");
// page properties
xwfb_edit.PageID = "edit"; // page ID
var EW_PAGE_ID = xwfb_edit.PageID; // for backward compatibility
// extend page with ValidateForm function
xwfb_edit.ValidateForm = function(fobj) {
	if (!this.ValidateRequired)
		return true; // ignore validation
	if (fobj.a_confirm && fobj.a_confirm.value == "F")
		return true;
	var i, elm, aelm, infix;
	var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
	for (i=0; i<rowcnt; i++) {
		infix = (fobj.key_count) ? String(i+1) : "";
		elm = fobj.elements["x" + infix + "_bh"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, "请输入必要内容 - 一级栏目");
		elm = fobj.elements["x" + infix + "_xwbt"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, "请输入必要内容 - 标题");
		elm = fobj.elements["x" + infix + "_fbsj"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, "请输入必要内容 - 发布时间");
		elm = fobj.elements["x" + infix + "_fbsj"];
		if (elm && !ew_CheckDate(elm.value))
			return ew_OnError(this, elm, "日期无效, 例 ： 年-月-日 - 发布时间");
		elm = fobj.elements["x" + infix + "_content"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, "请输入必要内容 - 详细内容");
		elm = fobj.elements["x" + infix + "_px"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "无效的整数型 - 排序");
		// Call Form Custom Validate event
		if (!this.Form_CustomValidate(fobj)) return false;
	}
	return true;
}
// extend page with Form_CustomValidate function
xwfb_edit.Form_CustomValidate = 
 function(fobj) { // DO NOT CHANGE THIS LINE!
 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
xwfb_edit.SelectAllKey = function(elem) {
	ew_SelectAll(elem);
}
<% If EW_CLIENT_VALIDATE Then %>
xwfb_edit.ValidateRequired = true; // uses JavaScript validation
<% Else %>
xwfb_edit.ValidateRequired = false; // no JavaScript validation
<% End If %>
//-->
</script>
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
<script type="text/javascript">
<!--
_width_multiplier = 16;
_height_multiplier = 60;
var ew_DHTMLEditors = [];
// update value from editor to textarea
function ew_UpdateTextArea() {
	if (typeof ew_DHTMLEditors != 'undefined' && typeof FCKeditorAPI != 'undefined') {			
			var inst;			
			for (inst in FCKeditorAPI.__Instances)
				FCKeditorAPI.__Instances[inst].UpdateLinkedField();
	}
}
// update value from textarea to editor
function ew_UpdateDHTMLEditor(name) {
	if (typeof ew_DHTMLEditors != 'undefined' && typeof FCKeditorAPI != 'undefined') {
		var inst = FCKeditorAPI.GetInstance(name);		
		if (inst)
			inst.SetHTML(inst.LinkedField.value)
	}
}
// focus editor
function ew_FocusDHTMLEditor(name) {
	if (typeof ew_DHTMLEditors != 'undefined' && typeof FCKeditorAPI != 'undefined') {
		var inst = FCKeditorAPI.GetInstance(name);	
		if (inst && inst.EditorWindow) {
			inst.EditorWindow.focus();
		}
	}
}
//-->
</script>
<link rel="stylesheet" type="text/css" media="all" href="calendar/calendar-win2k-1.css" title="win2k-1">
<script type="text/javascript" src="calendar/calendar.js"></script>
<script type="text/javascript" src="calendar/lang/calendar-en.js"></script>
<script type="text/javascript" src="calendar/calendar-setup.js"></script>
<link rel="stylesheet" href="../editor/themes/default/default.css" />
	<link rel="stylesheet" href="../editor/plugins/code/prettify.css" />
	<script charset="utf-8" src="../editor/kindeditor.js"></script>
	<script charset="utf-8" src="../editor/lang/zh_CN.js"></script>
	<script charset="utf-8" src="../editor/plugins/code/prettify.js"></script>
	<script>
		KindEditor.ready(function(K) {
			var editor1 = K.create('textarea[name="x_content"]', {
				cssPath : '../editor/plugins/code/prettify.css',
				uploadJson : '../editor/asp/upload_json.asp',
				fileManagerJson : '../editor/asp/file_manager_json.asp',
				allowFileManager : true,
				afterBlur : function() { this.sync(); K.ctrl(document, 13, function() {  K('form[name=fxwfbadd]')[0].submit(); }); K.ctrl(this.edit.doc, 13, function() {  K('form[name=fxwfbadd]')[0].submit(); });}
			});
			K('#image1').click(function() {
					editor1.loadPlugin('image', function() {
						editor1.plugin.imageDialog({
							imageUrl : K('#x_pic').val(),
							clickFn : function(url, title, width, height, border, align) {
								K('#x_pic').val(url);
								editor1.hideDialog();
							}
						});
					});
				});
		});
		
	</script>
<script language="JavaScript" type="text/javascript">
<!--
// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->
</script>
<p><span class="aspmaker">编辑 表: 信息管理<br><br>
<a href="<%= xwfb.ReturnUrl %>">返回</a></span></p>
<% xwfb_edit.ShowMessage %>
<form name="fxwfbedit" id="fxwfbedit" action="<%= ew_CurrentPage %>" method="post">
<p>
<input type="hidden" name="a_table" id="a_table" value="xwfb">
<input type="hidden" name="a_edit" id="a_edit" value="U">
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<% If xwfb.id.Visible Then ' id %>
	<tr<%= xwfb.id.RowAttributes %>>
		<td class="ewTableHeader">编号</td>
		<td<%= xwfb.id.CellAttributes %>><span id="el_id">
<div<%= xwfb.id.ViewAttributes %>><%= xwfb.id.EditValue %></div>
<input type="hidden" name="x_id" id="x_id" value="<%= Server.HTMLEncode(xwfb.id.CurrentValue&"") %>">
</span><%= xwfb.id.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwfb.bh.Visible Then ' bh %>
	<tr<%= xwfb.bh.RowAttributes %>>
		<td class="ewTableHeader">一级栏目<span class='ewmsg'>&nbsp;*</span></td>
		<td<%= xwfb.bh.CellAttributes %>><span id="el_bh">
<% If xwfb.bh.SessionValue <> "" Then %>
<div<%= xwfb.bh.ViewAttributes %>><%= xwfb.bh.ViewValue %></div>
<input type="hidden" id="x_bh" name="x_bh" value="<%= ew_HtmlEncode(xwfb.bh.CurrentValue) %>">
<% Else %>
<select id="x_bh" name="x_bh" onchange="ew_UpdateOpt('x_lmid','x_bh',xwfb_edit.ar_x_lmid);"<%= xwfb.bh.EditAttributes %>>
<%
emptywrk = True
If IsArray(xwfb.bh.EditValue) Then
	arwrk = xwfb.bh.EditValue
	For rowcntwrk = 0 To UBound(arwrk, 2)
		If arwrk(0, rowcntwrk)&"" = xwfb.bh.CurrentValue&"" Then
			selwrk = " selected=""selected"""
			emptywrk = False
		Else
			selwrk = ""
		End If
%>
<option value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %>>
<%= arwrk(1, rowcntwrk) %>
</option>
<%
	Next
End If
%>
</select>
<% End If %>
</span><%= xwfb.bh.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwfb.lmid.Visible Then ' lmid %>
	<tr<%= xwfb.lmid.RowAttributes %>>
		<td class="ewTableHeader">二级栏目</td>
		<td<%= xwfb.lmid.CellAttributes %>><span id="el_lmid">
<% If xwfb.lmid.SessionValue <> "" Then %>
<div<%= xwfb.lmid.ViewAttributes %>><%= xwfb.lmid.ViewValue %></div>
<input type="hidden" id="x_lmid" name="x_lmid" value="<%= ew_HtmlEncode(xwfb.lmid.CurrentValue) %>">
<% Else %>
<select id="x_lmid" name="x_lmid" onchange="ew_UpdateOpt('x_sj','x_lmid',xwfb_edit.ar_x_sj);"<%= xwfb.lmid.EditAttributes %>>
<%
emptywrk = True
If IsArray(xwfb.lmid.EditValue) Then
	arwrk = xwfb.lmid.EditValue
	For rowcntwrk = 0 To UBound(arwrk, 2)
		If arwrk(0, rowcntwrk)&"" = xwfb.lmid.CurrentValue&"" Then
			selwrk = " selected=""selected"""
			emptywrk = False
		Else
			selwrk = ""
		End If
%>
<option value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %>>
<%= arwrk(1, rowcntwrk) %>
</option>
<%
	Next
End If
%>
</select>
<%
jswrk = "" ' Initialise
If IsArray(xwfb.lmid.EditValue) Then
	arwrk = xwfb.lmid.EditValue
	For rowcntwrk = 1 To UBound(arwrk, 2)
		If jswrk <> "" Then jswrk = jswrk & ","
		jswrk = jswrk & "['" & ew_JsEncode(arwrk(0, rowcntwrk)) & "'," ' Value
		jswrk = jswrk & "'" & ew_JsEncode(arwrk(1, rowcntwrk)) & "'," ' Display field 1
		jswrk = jswrk & "'" & ew_JsEncode(arwrk(2, rowcntwrk)) & "'," ' Display field 2
		jswrk = jswrk & "'" & ew_JsEncode(arwrk(3, rowcntwrk)) & "']" ' Filter field
	Next
End If
%>
<script type="text/javascript">
<!--
xwfb_edit.ar_x_lmid = [<%= jswrk %>];
//-->
</script>
<% End If %>
</span><%= xwfb.lmid.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwfb.sj.Visible Then ' sj %>
	<tr<%= xwfb.sj.RowAttributes %>>
		<td class="ewTableHeader">三级栏目</td>
		<td<%= xwfb.sj.CellAttributes %>><span id="el_sj">
<% If xwfb.sj.SessionValue <> "" Then %>
<div<%= xwfb.sj.ViewAttributes %>><%= xwfb.sj.ViewValue %></div>
<input type="hidden" id="x_sj" name="x_sj" value="<%= ew_HtmlEncode(xwfb.sj.CurrentValue) %>">
<% Else %>
<select id="x_sj" name="x_sj"<%= xwfb.sj.EditAttributes %>>
<%
emptywrk = True
If IsArray(xwfb.sj.EditValue) Then
	arwrk = xwfb.sj.EditValue
	For rowcntwrk = 0 To UBound(arwrk, 2)
		If arwrk(0, rowcntwrk)&"" = xwfb.sj.CurrentValue&"" Then
			selwrk = " selected=""selected"""
			emptywrk = False
		Else
			selwrk = ""
		End If
%>
<option value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %>>
<%= arwrk(1, rowcntwrk) %>
</option>
<%
	Next
End If
%>
</select>
<%
jswrk = "" ' Initialise
If IsArray(xwfb.sj.EditValue) Then
	arwrk = xwfb.sj.EditValue
	For rowcntwrk = 1 To UBound(arwrk, 2)
		If jswrk <> "" Then jswrk = jswrk & ","
		jswrk = jswrk & "['" & ew_JsEncode(arwrk(0, rowcntwrk)) & "'," ' Value
		jswrk = jswrk & "'" & ew_JsEncode(arwrk(1, rowcntwrk)) & "'," ' Display field 1
		jswrk = jswrk & "'" & ew_JsEncode(arwrk(2, rowcntwrk)) & "'," ' Display field 2
		jswrk = jswrk & "'" & ew_JsEncode(arwrk(3, rowcntwrk)) & "']" ' Filter field
	Next
End If
%>
<script type="text/javascript">
<!--
xwfb_edit.ar_x_sj = [<%= jswrk %>];
//-->
</script>
<% End If %>
</span><%= xwfb.sj.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwfb.xwbt.Visible Then ' xwbt %>
	<tr<%= xwfb.xwbt.RowAttributes %>>
		<td class="ewTableHeader">标题<span class='ewmsg'>&nbsp;*</span></td>
		<td<%= xwfb.xwbt.CellAttributes %>><span id="el_xwbt">
<input type="text" name="x_xwbt" id="x_xwbt" size="30" maxlength="50" value="<%= xwfb.xwbt.EditValue %>"<%= xwfb.xwbt.EditAttributes %>>
</span><%= xwfb.xwbt.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwfb.fbsj.Visible Then ' fbsj %>
	<tr<%= xwfb.fbsj.RowAttributes %>>
		<td class="ewTableHeader">发布时间<span class='ewmsg'>&nbsp;*</span></td>
		<td<%= xwfb.fbsj.CellAttributes %>><span id="el_fbsj">
<input type="text" name="x_fbsj" id="x_fbsj" value="<%= xwfb.fbsj.EditValue %>"<%= xwfb.fbsj.EditAttributes %>>
&nbsp;<img src="images/calendar.png" id="cal_x_fbsj" name="cal_x_fbsj" alt="选择日期" style="cursor:pointer;cursor:hand;">
<script type="text/javascript">
Calendar.setup({
	inputField : "x_fbsj", // ID of the input field
	ifFormat : "%Y-%m-%d", // the date format
	button : "cal_x_fbsj" // ID of the button
});
</script>
</span><%= xwfb.fbsj.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwfb.pic.Visible Then ' pic %>
	<tr<%= xwfb.pic.RowAttributes %>>
		<td class="ewTableHeader">图片信息</td>
		<td<%= xwfb.pic.CellAttributes %>><span id="el_pic">
<input type="text" id="x_pic" name="x_pic" value="<%= xwfb.pic.EditValue %>" /> <input type="button" id="image1" value="选择图片" />
</span><%= xwfb.pic.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwfb.content.Visible Then ' content %>
	<tr<%= xwfb.content.RowAttributes %>>
		<td class="ewTableHeader">详细内容<span class='ewmsg'>&nbsp;*</span></td>
		<td<%= xwfb.content.CellAttributes %>><span id="el_content">
        <textarea id="x_content" name="x_content" style="width:700px;height:300px;"><%= xwfb.content.EditValue %></textarea>

</span><%= xwfb.content.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwfb.ishome.Visible Then ' ishome %>
	<tr<%= xwfb.ishome.RowAttributes %>>
		<td class="ewTableHeader">首页显示</td>
		<td<%= xwfb.ishome.CellAttributes %>><span id="el_ishome">
<div id="tp_x_ishome" class="<%= EW_ITEM_TEMPLATE_CLASSNAME %>"><input type="radio" name="x_ishome" id="x_ishome" value="{value}"<%= xwfb.ishome.EditAttributes %>></div>
<div id="dsl_x_ishome" repeatcolumn="5">
<%
emptywrk = True
arwrk = xwfb.ishome.EditValue
If IsArray(arwrk) Then
	rowswrk = UBound(arwrk, 2)	
	For rowcntwrk = 0 To rowswrk
		If xwfb.ishome.CurrentValue&"" = arwrk(0, rowcntwrk)&"" Then
			selwrk = " checked=""checked"""
			emptywrk = False
		Else
			selwrk = ""
		End If

		' Note: No spacing within the LABEL tag
%>
<%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 5, 1) %>
<label><input type="radio" name="x_ishome" id="x_ishome" value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %><%= xwfb.ishome.EditAttributes %>><%= arwrk(1, rowcntwrk) %></label>
<%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 5, 2) %>
<%
	Next
End If
%>
</div>
</span><%= xwfb.ishome.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwfb.px.Visible Then ' px %>
	<tr<%= xwfb.px.RowAttributes %>>
		<td class="ewTableHeader">排序</td>
		<td<%= xwfb.px.CellAttributes %>><span id="el_px">
<input type="text" name="x_px" id="x_px" size="30" value="<%= xwfb.px.EditValue %>"<%= xwfb.px.EditAttributes %>>
</span><%= xwfb.px.CustomMsg %></td>
	</tr>
<% End If %>
</table>
</div>
</td></tr></table>
<p>
<input type="button" name="btnAction" id="btnAction" value="    编辑    " onclick="ew_SubmitForm(xwfb_edit, this.form);">
</form>
<script language="JavaScript">
<!--
ew_UpdateOpts([['x_lmid','x_bh',xwfb_edit.ar_x_lmid],['x_sj','x_lmid',xwfb_edit.ar_x_sj]]);
//-->
</script>
<script type="text/javascript">
<!--
ew_CreateEditor();  // Create DHTML editor(s)
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
// Write your table-specific startup script here
// document.write("page loaded");
//-->
</script>
<!--#include file="footer.asp"-->
<%

' Drop page object
Set xwfb_edit = Nothing
%>
<%

' -----------------------------------------------------------------
' Page Class
'
Class cxwfb_edit

	' Page ID
	Public Property Get PageID()
		PageID = "edit"
	End Property

	' Table Name
	Public Property Get TableName()
		TableName = "xwfb"
	End Property

	' Page Object Name
	Public Property Get PageObjName()
		PageObjName = "xwfb_edit"
	End Property

	' Page Name
	Public Property Get PageName()
		PageName = ew_CurrentPage()
	End Property

	' Page Url
	Public Property Get PageUrl()
		PageUrl = ew_CurrentPage() & "?"
		If xwfb.UseTokenInUrl Then PageUrl = PageUrl & "t=" & xwfb.TableVar & "&" ' add page token
	End Property

	' Message
	Public Property Get Message()
		Message = Session(EW_SESSION_MESSAGE)
	End Property

	Public Property Let Message(v)
		If Session(EW_SESSION_MESSAGE) <> "" Then ' Append
			Session(EW_SESSION_MESSAGE) = Session(EW_SESSION_MESSAGE) & "<br>" & v
		Else
			Session(EW_SESSION_MESSAGE) = v
		End If
	End Property

	' Show Message
	Public Sub ShowMessage()
		If Message <> "" Then ' Message in Session, display
			Response.Write "<p><span class=""ewMessage"">" & Message & "</span></p>"
			Session(EW_SESSION_MESSAGE) = "" ' Clear message in Session
		End If
	End Sub

	' -----------------------
	'  Validate Page request
	'
	Public Function IsPageRequest()
		If xwfb.UseTokenInUrl Then
			IsPageRequest = False
			If Not (ObjForm Is Nothing) Then
				IsPageRequest = (xwfb.TableVar = ObjForm.GetValue("t"))
			End If
			If Request.QueryString("t").Count > 0 Then
				IsPageRequest = (xwfb.TableVar = Request.QueryString("t"))
			End If
		Else
			IsPageRequest = True
		End If
	End Function

	' -----------------------------------------------------------------
	'  Class initialize
	'  - init objects
	'  - open ADO connection
	'
	Private Sub Class_Initialize()

		' Initialize table object
		Set xwfb = New cxwfb

		' Initialize other table object
		Set bhlm = New cbhlm

		' Initialize other table object
		Set xwlm = New cxwlm

		' Initialize other table object
		Set zlogin = New czlogin

		' Initialize other table object
		Set sjlm = New csjlm

		' Initialize form object
		Set ObjForm = Nothing

		' Intialize page id (for backward compatibility)
		EW_PAGE_ID = "edit"

		' Initialize table name (for backward compatibility)
		EW_TABLE_NAME = "xwfb"

		' Open connection to the database
		Set Conn = Server.CreateObject("ADODB.Connection")
		Conn.Open EW_DB_CONNECTION_STRING
	End Sub

	' -----------------------------------------------------------------
	'  Subroutine Page_Init
	'  - called before page main
	'  - check Security
	'  - set up response header
	'  - call page load events
	'
	Sub Page_Init()
		Set Security = New cAdvancedSecurity
		If Not Security.IsLoggedIn() Then Call Security.AutoLogin()
		If Not Security.IsLoggedIn() Then
			Call Security.SaveLastUrl()
			Call Page_Terminate("login.asp")
		End If

		' Table Permission loading event
		Call Security.TablePermission_Loading()
		Call Security.LoadCurrentUserLevel(TableName)

		' Table Permission loaded event
		Call Security.TablePermission_Loaded()
		If Not Security.CanEdit Then
			Call Security.SaveLastUrl()
			Call Page_Terminate("xwfblist.asp")
		End If

		' Global page loading event (in userfn7.asp)
		Call Page_Loading()

		' Page load event, used in current page
		Call Page_Load()
	End Sub

	' -----------------------------------------------------------------
	'  Class terminate
	'  - clean up page object
	'
	Private Sub Class_Terminate()
		Call Page_Terminate("")
	End Sub

	' -----------------------------------------------------------------
	'  Subroutine Page_Terminate
	'  - called when exit page
	'  - clean up ADO connection and objects
	'  - if url specified, redirect to url
	'
	Sub Page_Terminate(url)

		' Page unload event, used in current page
		Call Page_Unload()

		' Global page unloaded event (in userfn60.asp)
		Call Page_Unloaded()
		If Not (Conn Is Nothing) Then Conn.Close ' Close Connection
		Set Conn = Nothing
		Set Security = Nothing
		Set xwfb = Nothing

		' Go to url if specified
		If url <> "" Then
			Response.Clear
			Response.Redirect url
		End If
	End Sub

	'
	'  Subroutine Page_Terminate (End)
	' ----------------------------------------
	' -----------------------------------------------------------------
	' Page main processing
	'
	Sub Page_Main()

		' Load key from QueryString
		If Request.QueryString("id").Count > 0 Then
			xwfb.id.QueryStringValue = Request.QueryString("id")
		End If

		' Create form object
		Set ObjForm = New cFormObj
		If ObjForm.GetValue("a_edit")&"" <> "" Then
			xwfb.CurrentAction = ObjForm.GetValue("a_edit") ' Get action code
			Call LoadFormValues() ' Get form values

			' Validate Form
			If Not ValidateForm() Then
				xwfb.CurrentAction = "" ' Form error, reset action
				Message = gsFormError
				Call LoadRow() ' Restore row
				Call RestoreFormValues() ' Restore form values if validate failed
			End If
		Else
			xwfb.CurrentAction = "I" ' Default action is display
		End If

		' Close form object
		Set ObjForm = Nothing

		' Check if valid key
		If xwfb.id.CurrentValue = "" Then Call Page_Terminate("xwfblist.asp") ' Invalid key, return to list
		Select Case xwfb.CurrentAction
			Case "I" ' Get a record to display
				If Not LoadRow() Then ' Load Record based on key
					Message = "没有找到记录" ' No record found
					Call Page_Terminate("xwfblist.asp") ' No matching record, return to list
				End If
			Case "U" ' Update
				xwfb.SendEmail = True ' Send email on update success
				If EditRow() Then ' Update Record based on key
					Message = "更新成功" ' Update success
					Dim sReturnUrl
					sReturnUrl = xwfb.ReturnUrl
					If ew_GetPageName(sReturnUrl) = "xwfbview.asp" Then sReturnUrl = xwfb.ViewUrl ' View paging, return to view page with keyurl directly
					Call Page_Terminate(sReturnUrl) ' Return to caller
				Else
					Call LoadRow() ' Restore row
					Call RestoreFormValues() ' Restore form values if update failed
				End If
		End Select

		' Render the record
		xwfb.RowType = EW_ROWTYPE_EDIT ' Render as edit

		' Render row
		Call RenderRow()
	End Sub

	' -----------------------------------------------------------------
	' Function Get upload files
	'
	Function GetUploadFiles()

		' Get upload data
	End Function

	' -----------------------------------------------------------------
	' Load form values
	'
	Function LoadFormValues()

		' Load values from form
		xwfb.id.FormValue = ObjForm.GetValue("x_id")
		xwfb.id.OldValue = ObjForm.GetValue("o_id")
		xwfb.bh.FormValue = ObjForm.GetValue("x_bh")
		xwfb.bh.OldValue = ObjForm.GetValue("o_bh")
		xwfb.lmid.FormValue = ObjForm.GetValue("x_lmid")
		xwfb.lmid.OldValue = ObjForm.GetValue("o_lmid")
		xwfb.sj.FormValue = ObjForm.GetValue("x_sj")
		xwfb.sj.OldValue = ObjForm.GetValue("o_sj")
		xwfb.xwbt.FormValue = ObjForm.GetValue("x_xwbt")
		xwfb.xwbt.OldValue = ObjForm.GetValue("o_xwbt")
		xwfb.fbsj.FormValue = ObjForm.GetValue("x_fbsj")
		xwfb.fbsj.CurrentValue = ew_UnFormatDateTime(xwfb.fbsj.CurrentValue, 5)
		xwfb.fbsj.OldValue = ObjForm.GetValue("o_fbsj")
		xwfb.pic.FormValue = ObjForm.GetValue("x_pic")
		xwfb.pic.OldValue = ObjForm.GetValue("o_pic")
		xwfb.content.FormValue = ObjForm.GetValue("x_content")
		xwfb.content.OldValue = ObjForm.GetValue("o_content")
		xwfb.ishome.FormValue = ObjForm.GetValue("x_ishome")
		xwfb.ishome.OldValue = ObjForm.GetValue("o_ishome")
		xwfb.px.FormValue = ObjForm.GetValue("x_px")
		xwfb.px.OldValue = ObjForm.GetValue("o_px")
	End Function

	' -----------------------------------------------------------------
	' Restore form values
	'
	Function RestoreFormValues()
		xwfb.id.CurrentValue = xwfb.id.FormValue
		xwfb.bh.CurrentValue = xwfb.bh.FormValue
		xwfb.lmid.CurrentValue = xwfb.lmid.FormValue
		xwfb.sj.CurrentValue = xwfb.sj.FormValue
		xwfb.xwbt.CurrentValue = xwfb.xwbt.FormValue
		xwfb.fbsj.CurrentValue = xwfb.fbsj.FormValue
		xwfb.fbsj.CurrentValue = ew_UnFormatDateTime(xwfb.fbsj.CurrentValue, 5)
		xwfb.pic.CurrentValue = xwfb.pic.FormValue
		xwfb.content.CurrentValue = xwfb.content.FormValue
		xwfb.ishome.CurrentValue = xwfb.ishome.FormValue
		xwfb.px.CurrentValue = xwfb.px.FormValue
	End Function

	' -----------------------------------------------------------------
	' Load row based on key values
	'
	Function LoadRow()
		Dim RsRow, sSql, sFilter
		sFilter = xwfb.KeyFilter

		' Call Row Selecting event
		Call xwfb.Row_Selecting(sFilter)

		' Load sql based on filter
		xwfb.CurrentFilter = sFilter
		sSql = xwfb.SQL
		If EW_DEBUG_ENABLED Then Response.Write sSql ' Show SQL for debugging
		Set RsRow = Server.CreateObject("ADODB.Recordset")
		RsRow.Open sSql, Conn
		If RsRow.Eof Then
			LoadRow = False
		Else
			LoadRow = True
			RsRow.MoveFirst
			Call LoadRowValues(RsRow) ' Load row values

			' Call Row Selected event
			Call xwfb.Row_Selected(RsRow)
		End If
		RsRow.Close
		Set RsRow = Nothing
	End Function

	' -----------------------------------------------------------------
	' Load row values from recordset
	'
	Sub LoadRowValues(RsRow)
		xwfb.id.DbValue = RsRow("id")
		xwfb.bh.DbValue = RsRow("bh")
		xwfb.lmid.DbValue = RsRow("lmid")
		xwfb.sj.DbValue = RsRow("sj")
		xwfb.xwbt.DbValue = RsRow("xwbt")
		xwfb.fbsj.DbValue = RsRow("fbsj")
		xwfb.pic.DbValue = RsRow("pic")
		xwfb.content.DbValue = RsRow("content")
		xwfb.ishome.DbValue = RsRow("ishome")
		xwfb.px.DbValue = RsRow("px")
	End Sub

	' -----------------------------------------------------------------
	' Render row values based on field settings
	'
	Sub RenderRow()

		' Call Row Rendering event
		Call xwfb.Row_Rendering()

		' ---------------------------------------
		'  Common render codes for all row types
		' ---------------------------------------
		' id

		xwfb.id.CellCssStyle = ""
		xwfb.id.CellCssClass = ""

		' bh
		xwfb.bh.CellCssStyle = ""
		xwfb.bh.CellCssClass = ""

		' lmid
		xwfb.lmid.CellCssStyle = ""
		xwfb.lmid.CellCssClass = ""

		' sj
		xwfb.sj.CellCssStyle = ""
		xwfb.sj.CellCssClass = ""

		' xwbt
		xwfb.xwbt.CellCssStyle = ""
		xwfb.xwbt.CellCssClass = ""

		' fbsj
		xwfb.fbsj.CellCssStyle = ""
		xwfb.fbsj.CellCssClass = ""

		' pic
		xwfb.pic.CellCssStyle = ""
		xwfb.pic.CellCssClass = ""

		' content
		xwfb.content.CellCssStyle = ""
		xwfb.content.CellCssClass = ""

		' ishome
		xwfb.ishome.CellCssStyle = ""
		xwfb.ishome.CellCssClass = ""

		' px
		xwfb.px.CellCssStyle = ""
		xwfb.px.CellCssClass = ""

		' -----------
		'  View  Row
		' -----------

		If xwfb.RowType = EW_ROWTYPE_VIEW Then ' View row

			' id
			xwfb.id.ViewValue = xwfb.id.CurrentValue
			xwfb.id.CssStyle = ""
			xwfb.id.CssClass = ""
			xwfb.id.ViewCustomAttributes = ""

			' bh
			If xwfb.bh.CurrentValue & "" <> "" Then
				sSqlWrk = "SELECT [bhmc] FROM [bhlm] WHERE [bh] = " & ew_AdjustSql(xwfb.bh.CurrentValue) & ""
				Set RsWrk = Conn.Execute(sSqlWrk)
				If Not RsWrk.Eof Then
					xwfb.bh.ViewValue = RsWrk("bhmc")
				Else
					xwfb.bh.ViewValue = xwfb.bh.CurrentValue
				End If
				RsWrk.Close
				Set RsWrk = Nothing
			Else
				xwfb.bh.ViewValue = Null
			End If
			xwfb.bh.CssStyle = ""
			xwfb.bh.CssClass = ""
			xwfb.bh.ViewCustomAttributes = ""

			' lmid
			If xwfb.lmid.CurrentValue & "" <> "" Then
				sSqlWrk = "SELECT [lmmc] FROM [xwlm] WHERE [lmid] = " & ew_AdjustSql(xwfb.lmid.CurrentValue) & ""
				Set RsWrk = Conn.Execute(sSqlWrk)
				If Not RsWrk.Eof Then
					xwfb.lmid.ViewValue = RsWrk("lmmc")
				Else
					xwfb.lmid.ViewValue = xwfb.lmid.CurrentValue
				End If
				RsWrk.Close
				Set RsWrk = Nothing
			Else
				xwfb.lmid.ViewValue = Null
			End If
			xwfb.lmid.CssStyle = ""
			xwfb.lmid.CssClass = ""
			xwfb.lmid.ViewCustomAttributes = ""

			' sj
			If xwfb.sj.CurrentValue & "" <> "" Then
				sSqlWrk = "SELECT [sjmc] FROM [sjlm] WHERE [id] = " & ew_AdjustSql(xwfb.sj.CurrentValue) & ""
				Set RsWrk = Conn.Execute(sSqlWrk)
				If Not RsWrk.Eof Then
					xwfb.sj.ViewValue = RsWrk("sjmc")
				Else
					xwfb.sj.ViewValue = xwfb.sj.CurrentValue
				End If
				RsWrk.Close
				Set RsWrk = Nothing
			Else
				xwfb.sj.ViewValue = Null
			End If
			xwfb.sj.CssStyle = ""
			xwfb.sj.CssClass = ""
			xwfb.sj.ViewCustomAttributes = ""

			' xwbt
			xwfb.xwbt.ViewValue = xwfb.xwbt.CurrentValue
			xwfb.xwbt.CssStyle = ""
			xwfb.xwbt.CssClass = ""
			xwfb.xwbt.ViewCustomAttributes = ""

			' fbsj
			xwfb.fbsj.ViewValue = xwfb.fbsj.CurrentValue
			xwfb.fbsj.ViewValue = ew_FormatDateTime(xwfb.fbsj.ViewValue, 5)
			xwfb.fbsj.CssStyle = ""
			xwfb.fbsj.CssClass = ""
			xwfb.fbsj.ViewCustomAttributes = ""

			' pic
			xwfb.pic.ViewValue = xwfb.pic.CurrentValue
			xwfb.pic.CssStyle = ""
			xwfb.pic.CssClass = ""
			xwfb.pic.ViewCustomAttributes = ""

			' content
			xwfb.content.ViewValue = xwfb.content.CurrentValue
			xwfb.content.CssStyle = ""
			xwfb.content.CssClass = ""
			xwfb.content.ViewCustomAttributes = ""

			' ishome
			If Not IsNull(xwfb.ishome.CurrentValue) Then
				Select Case xwfb.ishome.CurrentValue
					Case "0"
						xwfb.ishome.ViewValue = "否"
					Case "1"
						xwfb.ishome.ViewValue = "是"
					Case Else
						xwfb.ishome.ViewValue = xwfb.ishome.CurrentValue
				End Select
			Else
				xwfb.ishome.ViewValue = Null
			End If
			xwfb.ishome.CssStyle = ""
			xwfb.ishome.CssClass = ""
			xwfb.ishome.ViewCustomAttributes = ""

			' px
			xwfb.px.ViewValue = xwfb.px.CurrentValue
			xwfb.px.CssStyle = ""
			xwfb.px.CssClass = ""
			xwfb.px.ViewCustomAttributes = ""

			' View refer script
			' id

			xwfb.id.HrefValue = ""

			' bh
			xwfb.bh.HrefValue = ""

			' lmid
			xwfb.lmid.HrefValue = ""

			' sj
			xwfb.sj.HrefValue = ""

			' xwbt
			xwfb.xwbt.HrefValue = ""

			' fbsj
			xwfb.fbsj.HrefValue = ""

			' pic
			xwfb.pic.HrefValue = ""

			' content
			xwfb.content.HrefValue = ""

			' ishome
			xwfb.ishome.HrefValue = ""

			' px
			xwfb.px.HrefValue = ""

		' ----------
		'  Edit Row
		' ----------

		ElseIf xwfb.RowType = EW_ROWTYPE_EDIT Then ' Edit row

			' id
			xwfb.id.EditCustomAttributes = ""
			xwfb.id.EditValue = xwfb.id.CurrentValue
			xwfb.id.CssStyle = ""
			xwfb.id.CssClass = ""
			xwfb.id.ViewCustomAttributes = ""

			' bh
			xwfb.bh.EditCustomAttributes = ""
			If xwfb.bh.SessionValue <> "" Then
				xwfb.bh.CurrentValue = xwfb.bh.SessionValue
			If xwfb.bh.CurrentValue & "" <> "" Then
				sSqlWrk = "SELECT [bhmc] FROM [bhlm] WHERE [bh] = " & ew_AdjustSql(xwfb.bh.CurrentValue) & ""
				Set RsWrk = Conn.Execute(sSqlWrk)
				If Not RsWrk.Eof Then
					xwfb.bh.ViewValue = RsWrk("bhmc")
				Else
					xwfb.bh.ViewValue = xwfb.bh.CurrentValue
				End If
				RsWrk.Close
				Set RsWrk = Nothing
			Else
				xwfb.bh.ViewValue = Null
			End If
			xwfb.bh.CssStyle = ""
			xwfb.bh.CssClass = ""
			xwfb.bh.ViewCustomAttributes = ""
			Else
			sSqlWrk = "SELECT [bh], [bhmc], '' AS Disp2Fld, '' AS SelectFilterFld FROM [bhlm]"
			sWhereWrk = ""
			If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
			Set RsWrk = Server.CreateObject("ADODB.Recordset")
			RsWrk.Open sSqlWrk, Conn
			If Not RsWrk.Eof Then
				arwrk = RsWrk.GetRows
			Else
				arwrk = ""
			End If
			RsWrk.Close
			Set RsWrk = Nothing
			arwrk = ew_AddItemToArray(arwrk, 0, Array("", "请选择"))
			xwfb.bh.EditValue = arwrk
			End If

			' lmid
			xwfb.lmid.EditCustomAttributes = ""
			If xwfb.lmid.SessionValue <> "" Then
				xwfb.lmid.CurrentValue = xwfb.lmid.SessionValue
			If xwfb.lmid.CurrentValue & "" <> "" Then
				sSqlWrk = "SELECT [lmmc] FROM [xwlm] WHERE [lmid] = " & ew_AdjustSql(xwfb.lmid.CurrentValue) & ""
				Set RsWrk = Conn.Execute(sSqlWrk)
				If Not RsWrk.Eof Then
					xwfb.lmid.ViewValue = RsWrk("lmmc")
				Else
					xwfb.lmid.ViewValue = xwfb.lmid.CurrentValue
				End If
				RsWrk.Close
				Set RsWrk = Nothing
			Else
				xwfb.lmid.ViewValue = Null
			End If
			xwfb.lmid.CssStyle = ""
			xwfb.lmid.CssClass = ""
			xwfb.lmid.ViewCustomAttributes = ""
			Else
			sSqlWrk = "SELECT [lmid], [lmmc], '' AS Disp2Fld, [bh] FROM [xwlm]"
			sWhereWrk = ""
			If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
			Set RsWrk = Server.CreateObject("ADODB.Recordset")
			RsWrk.Open sSqlWrk, Conn
			If Not RsWrk.Eof Then
				arwrk = RsWrk.GetRows
			Else
				arwrk = ""
			End If
			RsWrk.Close
			Set RsWrk = Nothing
			arwrk = ew_AddItemToArray(arwrk, 0, Array("", "请选择", ""))
			xwfb.lmid.EditValue = arwrk
			End If

			' sj
			xwfb.sj.EditCustomAttributes = ""
			If xwfb.sj.SessionValue <> "" Then
				xwfb.sj.CurrentValue = xwfb.sj.SessionValue
			If xwfb.sj.CurrentValue & "" <> "" Then
				sSqlWrk = "SELECT [sjmc] FROM [sjlm] WHERE [id] = " & ew_AdjustSql(xwfb.sj.CurrentValue) & ""
				Set RsWrk = Conn.Execute(sSqlWrk)
				If Not RsWrk.Eof Then
					xwfb.sj.ViewValue = RsWrk("sjmc")
				Else
					xwfb.sj.ViewValue = xwfb.sj.CurrentValue
				End If
				RsWrk.Close
				Set RsWrk = Nothing
			Else
				xwfb.sj.ViewValue = Null
			End If
			xwfb.sj.CssStyle = ""
			xwfb.sj.CssClass = ""
			xwfb.sj.ViewCustomAttributes = ""
			Else
			sSqlWrk = "SELECT [id], [sjmc], '' AS Disp2Fld, [lmid] FROM [sjlm]"
			sWhereWrk = ""
			If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
			Set RsWrk = Server.CreateObject("ADODB.Recordset")
			RsWrk.Open sSqlWrk, Conn
			If Not RsWrk.Eof Then
				arwrk = RsWrk.GetRows
			Else
				arwrk = ""
			End If
			RsWrk.Close
			Set RsWrk = Nothing
			arwrk = ew_AddItemToArray(arwrk, 0, Array("", "请选择", ""))
			xwfb.sj.EditValue = arwrk
			End If

			' xwbt
			xwfb.xwbt.EditCustomAttributes = ""
			xwfb.xwbt.EditValue = ew_HtmlEncode(xwfb.xwbt.CurrentValue)

			' fbsj
			xwfb.fbsj.EditCustomAttributes = ""
			xwfb.fbsj.EditValue = ew_FormatDateTime(xwfb.fbsj.CurrentValue, 5)

			' pic
			xwfb.pic.EditCustomAttributes = ""
			xwfb.pic.EditValue = ew_HtmlEncode(xwfb.pic.CurrentValue)

			' content
			xwfb.content.EditCustomAttributes = ""
			xwfb.content.EditValue = ew_HtmlEncode(xwfb.content.CurrentValue)

			' ishome
			xwfb.ishome.EditCustomAttributes = ""
			Redim arwrk(1, 1)
			arwrk(0, 0) = "0"
			arwrk(1, 0) = "否"
			arwrk(0, 1) = "1"
			arwrk(1, 1) = "是"
			xwfb.ishome.EditValue = arwrk

			' px
			xwfb.px.EditCustomAttributes = ""
			xwfb.px.EditValue = ew_HtmlEncode(xwfb.px.CurrentValue)

			' Edit refer script
			' id

			xwfb.id.HrefValue = ""

			' bh
			xwfb.bh.HrefValue = ""

			' lmid
			xwfb.lmid.HrefValue = ""

			' sj
			xwfb.sj.HrefValue = ""

			' xwbt
			xwfb.xwbt.HrefValue = ""

			' fbsj
			xwfb.fbsj.HrefValue = ""

			' pic
			xwfb.pic.HrefValue = ""

			' content
			xwfb.content.HrefValue = ""

			' ishome
			xwfb.ishome.HrefValue = ""

			' px
			xwfb.px.HrefValue = ""
		End If

		' Call Row Rendered event
		Call xwfb.Row_Rendered()
	End Sub

	' -----------------------------------------------------------------
	' Validate form
	'
	Function ValidateForm()

		' Initialize
		gsFormError = ""

		' Check if validation required
		If Not EW_SERVER_VALIDATE Then
			ValidateForm = (gsFormError = "")
			Exit Function
		End If
		If xwfb.bh.FormValue&"" = "" Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & "请输入必要内容 - 一级栏目"
		End If
		If xwfb.xwbt.FormValue&"" = "" Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & "请输入必要内容 - 标题"
		End If
		If xwfb.fbsj.FormValue&"" = "" Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & "请输入必要内容 - 发布时间"
		End If
		If Not ew_CheckDate(xwfb.fbsj.FormValue) Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & "日期无效, 例 ： 年-月-日 - 发布时间"
		End If
		If xwfb.content.FormValue&"" = "" Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & "请输入必要内容 - 详细内容"
		End If
		If Not ew_CheckInteger(xwfb.px.FormValue) Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & "无效的整数型 - 排序"
		End If

		' Return validate result
		ValidateForm = (gsFormError = "")

		' Call Form Custom Validate event
		Dim sFormCustomError
		sFormCustomError = ""
		ValidateForm = ValidateForm And Form_CustomValidate(sFormCustomError)
		If sFormCustomError <> "" Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & sFormCustomError
		End If
	End Function

	' -----------------------------------------------------------------
	' Update record based on key values
	'
	Function EditRow()
		If Not EW_DEBUG_ENABLED Then On Error Resume Next
		Dim Rs, sSql, sFilter
		Dim RsChk, sSqlChk, sFilterChk
		Dim bUpdateRow
		Dim RsOld, RsNew
		Dim sIdxErrMsg

		' Clear any previous errors
		Err.Clear
		sFilter = xwfb.KeyFilter
		xwfb.CurrentFilter  = sFilter
		sSql = xwfb.SQL
		Set Rs = Server.CreateObject("ADODB.Recordset")
		Rs.CursorLocation = EW_CURSORLOCATION
		Rs.Open sSql, Conn, 1, 2
		If Err.Number <> 0 Then
			Message = Err.Description
			Rs.Close
			Set Rs = Nothing
			EditRow = False
			Exit Function
		End If

		' Clone old recordset object
		Set RsOld = ew_CloneRs(Rs)
		If Rs.Eof Then
			EditRow = False ' Update Failed
		Else

			' Field id
			' Field bh

			Call xwfb.bh.SetDbValue(xwfb.bh.CurrentValue, Null)
			Rs("bh") = xwfb.bh.DbValue

			' Field lmid
			Call xwfb.lmid.SetDbValue(xwfb.lmid.CurrentValue, Null)
			Rs("lmid") = xwfb.lmid.DbValue

			' Field sj
			Call xwfb.sj.SetDbValue(xwfb.sj.CurrentValue, Null)
			Rs("sj") = xwfb.sj.DbValue

			' Field xwbt
			Call xwfb.xwbt.SetDbValue(xwfb.xwbt.CurrentValue, Null)
			Rs("xwbt") = xwfb.xwbt.DbValue

			' Field fbsj
			Call xwfb.fbsj.SetDbValue(ew_UnFormatDateTime(xwfb.fbsj.CurrentValue, 5), Null)
			Rs("fbsj") = xwfb.fbsj.DbValue

			' Field pic
			Call xwfb.pic.SetDbValue(xwfb.pic.CurrentValue, Null)
			Rs("pic") = xwfb.pic.DbValue

			' Field content
			Call xwfb.content.SetDbValue(xwfb.content.CurrentValue, Null)
			Rs("content") = xwfb.content.DbValue

			' Field ishome
			Call xwfb.ishome.SetDbValue(xwfb.ishome.CurrentValue, Null)
			Rs("ishome") = xwfb.ishome.DbValue

			' Field px
			Call xwfb.px.SetDbValue(xwfb.px.CurrentValue, Null)
			Rs("px") = xwfb.px.DbValue

			' Check recordset update error
			If Err.Number <> 0 Then
				Message = Err.Description
				Rs.Close
				Set Rs = Nothing
				EditRow = False
				Exit Function
			End If

			' Call Row Updating event
			bUpdateRow = xwfb.Row_Updating(RsOld, Rs)
			If bUpdateRow Then

				' Clone new recordset object
				Set RsNew = ew_CloneRs(Rs)
				Rs.Update
				If Err.Number <> 0 Then
					Message = Err.Description
					EditRow = False
				Else
					EditRow = True
				End If
			Else
				Rs.CancelUpdate
				If xwfb.CancelMessage <> "" Then
					Message = xwfb.CancelMessage
					xwfb.CancelMessage = ""
				Else
					Message = "取消更新"
				End If
				EditRow = False
			End If
		End If

		' Call Row Updated event
		If EditRow Then
			Call xwfb.Row_Updated(RsOld, RsNew)
		End If
		Rs.Close
		Set Rs = Nothing
		If IsObject(RsOld) Then
			RsOld.Close
			Set RsOld = Nothing
		End If
		If IsObject(RsNew) Then
			RsNew.Close
			Set RsNew = Nothing
		End If
	End Function

	' Page Load event
	Sub Page_Load()

		'Response.Write "Page Load"
	End Sub

	' Page Unload event
	Sub Page_Unload()

		'Response.Write "Page Unload"
	End Sub

	' Form Custom Validate event
	Function Form_CustomValidate(CustomError)

		'Return error message in CustomError
		Form_CustomValidate = True
	End Function
End Class
%>
