<%@ CodePage=65001 %> <% Const EW_PAGE_ID = "view" Const EW_TABLE_NAME = "Photo_Gallery" %> <% Session.Timeout = 100 %> <% Response.Expires = 0 Response.ExpiresAbsolute = Now() - 1 Response.AddHeader "pragma", "no-cache" Response.AddHeader "cache-control", "private, no-cache, no-store, must-revalidate" %> <% ' Open connection to the database Dim conn Set conn = Server.CreateObject("ADODB.Connection") conn.Open EW_DB_CONNECTION_STRING %> <% Dim Security 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 %> <% ' Common page loading event (in userfn60.asp) Call Page_Loading() %> <% ' Page load event, used in current page Call Page_Load() %> <% Response.Buffer = True If Request.QueryString("ID").Count > 0 Then Photo_Gallery.ID.QueryStringValue = Request.QueryString("ID") Else Call Page_Terminate("Photo_Gallerylist.asp") ' Return to list page End If ' Get action If Request.Form("a_view").Count > 0 Then Photo_Gallery.CurrentAction = Request.Form("a_view") Else Photo_Gallery.CurrentAction = "I" ' Display form End If Select Case Photo_Gallery.CurrentAction Case "I" ' Get a record to display If Not LoadRow() Then ' Load record based on key Session(EW_SESSION_MESSAGE) = "No records found" ' Set no record message Call Page_Terminate("Photo_Gallerylist.asp") ' Return to list End If End Select ' Set return url Photo_Gallery.ReturnUrl = "Photo_Galleryview.asp" ' Render row Photo_Gallery.RowType = EW_ROWTYPE_VIEW Call RenderRow() %>

View TABLE: Photo Gallery

Back to List  <% If Security.IsLoggedIn() Then %> Add  <% End If %> <% If Security.IsLoggedIn() Then %> Edit  <% End If %> <% If Security.IsLoggedIn() Then %> Copy  <% End If %> <% If Security.IsLoggedIn() Then %> Delete  <% End If %>

<% If Session(EW_SESSION_MESSAGE) <> "" Then %>

<%= Session(EW_SESSION_MESSAGE) %>

<% Session(EW_SESSION_MESSAGE) = "" ' Clear message End If %>

> ><%= Photo_Gallery.ID.ViewValue %> > ><%= Photo_Gallery.Photo_Category.ViewValue %> > ><%= Photo_Gallery.Photo_Title.ViewValue %> > <% If Photo_Gallery.Thumb_File.HrefValue <> "" Then %> <% If Not IsNull(Photo_Gallery.Thumb_File.Upload.DbValue) Then %> " border=0<%= Photo_Gallery.Thumb_File.ViewAttributes %>> <% End If %> <% Else %> <% If Not IsNull(Photo_Gallery.Thumb_File.Upload.DbValue) Then %> " border=0<%= Photo_Gallery.Thumb_File.ViewAttributes %>> <% End If %> <% End If %> > <% If Photo_Gallery.Photo_File.HrefValue <> "" Then %> <% If Not IsNull(Photo_Gallery.Photo_File.Upload.DbValue) Then %> " border=0<%= Photo_Gallery.Photo_File.ViewAttributes %>> <% End If %> <% Else %> <% If Not IsNull(Photo_Gallery.Photo_File.Upload.DbValue) Then %> " border=0<%= Photo_Gallery.Photo_File.ViewAttributes %>> <% End If %> <% End If %> > ><%= Photo_Gallery.CreatedDate.ViewValue %>
ID
Photo Category
Photo Title
Thumb File
Photo file
Created Date

<% ' If control is passed here, simply terminate the page without redirect Call Page_Terminate("") ' ----------------------------------------------------------------- ' Subroutine Page_Terminate ' - called when exit page ' - clean up ADO connection and objects ' - if url specified, redirect to url, otherwise end response ' Sub Page_Terminate(url) ' Page unload event, used in current page Call Page_Unload() ' Global page unloaded event (in userfn60.asp) Call Page_Unloaded() conn.Close ' Close Connection Set conn = Nothing Set Security = Nothing Set Photo_Gallery = Nothing ' Go to url if specified If url <> "" Then Response.Clear Response.Redirect url End If ' Terminate response Response.End End Sub ' ' Subroutine Page_Terminate (End) ' ---------------------------------------- %> <% ' Load row based on key values Function LoadRow() Dim rs, sSql, sFilter sFilter = Photo_Gallery.SqlKeyFilter If Not IsNumeric(Photo_Gallery.ID.CurrentValue) Then LoadRow = False ' Invalid key, exit Exit Function End If sFilter = Replace(sFilter, "@ID@", ew_AdjustSql(Photo_Gallery.ID.CurrentValue)) ' Replace key value ' Call Row Selecting event Call Photo_Gallery.Row_Selecting(sFilter) ' Load sql based on filter Photo_Gallery.CurrentFilter = sFilter sSql = Photo_Gallery.SQL Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sSql, conn If rs.Eof Then LoadRow = False Else LoadRow = True rs.MoveFirst Call LoadRowValues(rs) ' Load row values ' Call Row Selected event Call Photo_Gallery.Row_Selected(rs) End If rs.Close Set rs = Nothing End Function ' Load row values from recordset Sub LoadRowValues(rs) Photo_Gallery.ID.DbValue = rs("ID") Photo_Gallery.Photo_Category.DbValue = rs("Photo_Category") Photo_Gallery.Photo_Title.DbValue = rs("Photo_Title") Photo_Gallery.Thumb_File.Upload.DbValue = rs("Thumb_File") Photo_Gallery.Photo_File.Upload.DbValue = rs("Photo_File") Photo_Gallery.CreatedDate.DbValue = rs("CreatedDate") End Sub %> <% ' Render row values based on field settings Sub RenderRow() ' Call Row Rendering event Call Photo_Gallery.Row_Rendering() ' Common render codes for all row types ' ID Photo_Gallery.ID.CellCssStyle = "" Photo_Gallery.ID.CellCssClass = "" ' Photo_Category Photo_Gallery.Photo_Category.CellCssStyle = "" Photo_Gallery.Photo_Category.CellCssClass = "" ' Photo_Title Photo_Gallery.Photo_Title.CellCssStyle = "" Photo_Gallery.Photo_Title.CellCssClass = "" ' Thumb_File Photo_Gallery.Thumb_File.CellCssStyle = "" Photo_Gallery.Thumb_File.CellCssClass = "" ' Photo_File Photo_Gallery.Photo_File.CellCssStyle = "" Photo_Gallery.Photo_File.CellCssClass = "" ' CreatedDate Photo_Gallery.CreatedDate.CellCssStyle = "" Photo_Gallery.CreatedDate.CellCssClass = "" If Photo_Gallery.RowType = EW_ROWTYPE_VIEW Then ' View row ' ID Photo_Gallery.ID.ViewValue = Photo_Gallery.ID.CurrentValue Photo_Gallery.ID.CssStyle = "" Photo_Gallery.ID.CssClass = "" Photo_Gallery.ID.ViewCustomAttributes = "" ' Photo_Category If Not IsNull(Photo_Gallery.Photo_Category.CurrentValue) And Photo_Gallery.Photo_Category.CurrentValue <> "" Then sSqlWrk = "SELECT [Category_Name] FROM [Gallery_Category] WHERE [ID] = " & ew_AdjustSql(Photo_Gallery.Photo_Category.CurrentValue) & "" sSqlWrk = sSqlWrk & " ORDER BY [Category_Name] Asc" Set rswrk = conn.Execute(sSqlWrk) If Not rswrk.Eof Then Photo_Gallery.Photo_Category.ViewValue = rswrk("Category_Name") Else Photo_Gallery.Photo_Category.ViewValue = Photo_Gallery.Photo_Category.CurrentValue End If rswrk.Close Set rswrk = Nothing Else Photo_Gallery.Photo_Category.ViewValue = Null End If Photo_Gallery.Photo_Category.CssStyle = "" Photo_Gallery.Photo_Category.CssClass = "" Photo_Gallery.Photo_Category.ViewCustomAttributes = "" ' Photo_Title Photo_Gallery.Photo_Title.ViewValue = Photo_Gallery.Photo_Title.CurrentValue Photo_Gallery.Photo_Title.CssStyle = "" Photo_Gallery.Photo_Title.CssClass = "" Photo_Gallery.Photo_Title.ViewCustomAttributes = "" ' Thumb_File If Not IsNull(Photo_Gallery.Thumb_File.Upload.DbValue) Then Photo_Gallery.Thumb_File.ViewValue = Photo_Gallery.Thumb_File.Upload.DbValue Photo_Gallery.Thumb_File.ImageAlt = "" Else Photo_Gallery.Thumb_File.ViewValue = "" End If Photo_Gallery.Thumb_File.CssStyle = "" Photo_Gallery.Thumb_File.CssClass = "" Photo_Gallery.Thumb_File.ViewCustomAttributes = "" ' Photo_File If Not IsNull(Photo_Gallery.Photo_File.Upload.DbValue) Then Photo_Gallery.Photo_File.ViewValue = Photo_Gallery.Photo_File.Upload.DbValue Photo_Gallery.Photo_File.ImageAlt = "" Else Photo_Gallery.Photo_File.ViewValue = "" End If Photo_Gallery.Photo_File.CssStyle = "" Photo_Gallery.Photo_File.CssClass = "" Photo_Gallery.Photo_File.ViewCustomAttributes = "" ' CreatedDate Photo_Gallery.CreatedDate.ViewValue = Photo_Gallery.CreatedDate.CurrentValue Photo_Gallery.CreatedDate.ViewValue = ew_FormatDateTime(Photo_Gallery.CreatedDate.ViewValue, 7) Photo_Gallery.CreatedDate.CssStyle = "" Photo_Gallery.CreatedDate.CssClass = "" Photo_Gallery.CreatedDate.ViewCustomAttributes = "" ' ID ' *** view refer script Photo_Gallery.ID.HrefValue = "" ' Photo_Category ' *** view refer script Photo_Gallery.Photo_Category.HrefValue = "" ' Photo_Title ' *** view refer script Photo_Gallery.Photo_Title.HrefValue = "" ' Thumb_File ' *** view refer script Photo_Gallery.Thumb_File.HrefValue = "" ' Photo_File ' *** view refer script Photo_Gallery.Photo_File.HrefValue = "" ' CreatedDate ' *** view refer script Photo_Gallery.CreatedDate.HrefValue = "" ElseIf Photo_Gallery.RowType = EW_ROWTYPE_ADD Then ' Add row ElseIf Photo_Gallery.RowType = EW_ROWTYPE_EDIT Then ' Edit row ElseIf Photo_Gallery.RowType = EW_ROWTYPE_SEARCH Then ' Search row End If ' Call Row Rendered event Call Photo_Gallery.Row_Rendered() End Sub %> <% ' Set up Starting Record parameters based on Pager Navigation Sub SetUpStartRec() Dim nPageNo ' Exit if nDisplayRecs = 0 If nDisplayRecs = 0 Then Exit Sub ' Check for a START parameter If Request.QueryString(EW_TABLE_START_REC).Count > 0 Then nStartRec = Request.QueryString(EW_TABLE_START_REC) Photo_Gallery.StartRecordNumber = nStartRec ElseIf Request.QueryString(EW_TABLE_PAGE_NO).Count > 0 Then nPageNo = Request.QueryString(EW_TABLE_PAGE_NO) If IsNumeric(nPageNo) Then nStartRec = (nPageNo-1)*nDisplayRecs+1 If nStartRec <= 0 Then nStartRec = 1 ElseIf nStartRec >= ((nTotalRecs-1)\nDisplayRecs)*nDisplayRecs+1 Then nStartRec = ((nTotalRecs-1)\nDisplayRecs)*nDisplayRecs+1 End If Photo_Gallery.StartRecordNumber = nStartRec Else nStartRec = Photo_Gallery.StartRecordNumber End If Else nStartRec = Photo_Gallery.StartRecordNumber End If ' Check if correct start record counter If Not IsNumeric(nStartRec) Or nStartRec = "" Then ' Avoid invalid start record counter nStartRec = 1 ' Reset start record counter Photo_Gallery.StartRecordNumber = nStartRec ElseIf CLng(nStartRec) > CLng(nTotalRecs) Then ' Avoid starting record > total records nStartRec = ((nTotalRecs-1)\nDisplayRecs)*nDisplayRecs+1 ' Point to last page first record Photo_Gallery.StartRecordNumber = nStartRec ElseIf (nStartRec-1) Mod nDisplayRecs <> 0 Then nStartRec = ((nStartRec-1)\nDisplayRecs)*nDisplayRecs+1 ' Point to page boundary Photo_Gallery.StartRecordNumber = nStartRec End If End Sub %> <% ' Page Load event Sub Page_Load() '***Response.Write "Page Load" End Sub ' Page Unload event Sub Page_Unload() '***Response.Write "Page Unload" End Sub %>