Imports BVSoftware.BVC.Core Public Class content_custompages_edit Inherits BaseAdminPage Protected WithEvents inName As System.Web.UI.WebControls.TextBox Protected WithEvents inMenuName As System.Web.UI.WebControls.TextBox Protected WithEvents chkShowInBottomMenu As System.Web.UI.WebControls.CheckBox Protected WithEvents btnCancel As System.Web.UI.WebControls.ImageButton Protected WithEvents btnSave As System.Web.UI.WebControls.ImageButton Protected WithEvents MenuButton As System.Web.UI.WebControls.Image Protected WithEvents btnUpload As System.Web.UI.WebControls.ImageButton Protected WithEvents inImageURL As System.Web.UI.HtmlControls.HtmlInputFile Protected WithEvents RemoveButton As System.Web.UI.WebControls.ImageButton Protected WithEvents ButtonAnim As System.Web.UI.WebControls.Literal Protected WithEvents FirstFocus1 As MetaBuilders.WebControls.FirstFocus Protected WithEvents DefaultButtons1 As MetaBuilders.WebControls.DefaultButtons Protected WithEvents MetaTag1 As BVSoftware.WebControls.MetaTag Protected WithEvents MetaDescriptionControl As BVSoftware.WebControls.MetaTag Protected WithEvents MetaKeywordsControl As BVSoftware.WebControls.MetaTag Protected WithEvents DescriptionField As System.Web.UI.WebControls.TextBox Protected WithEvents msg As BVSoftware.WebControls.WebPageMessage Protected WithEvents inEditID As System.Web.UI.WebControls.TextBox #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load BVC2004Store.CheckThisPage(Security.RolePermission.LoginToAdmin) BVC2004Store.CheckThisPage(Security.RolePermission.AccessContentArea) If Not Page.IsPostBack Then MetaKeywordsControl.Content = WebAppSettings.MetaKeywords MetaDescriptionControl.Content = WebAppSettings.MetaDescription End If If Not Page.IsPostBack() Then Dim sEditID As String sEditID = Request.Params("id") If sEditID = Nothing Then Response.Redirect("content_custompages.aspx", True) Else Dim oPage As New Content.CustomPage If oPage.Load(Convert.ToInt32(sEditID)) = True Then inEditID.Text = sEditID inName.Text = oPage.Name DescriptionField.Text = oPage.Content inMenuName.Text = oPage.MenuName If oPage.ShowInBottomMenu = 1 Then chkShowInBottomMenu.Checked = True End If LoadMenuImage() Else Response.Redirect("content_custompages.aspx", True) End If oPage = Nothing End If End If End Sub Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnCancel.Click Response.Redirect("content_custompages.aspx", True) End Sub Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnSave.Click msg.Clear() Try Dim oPage As New Content.CustomPage If oPage.Load(Convert.ToInt32(inEditID.Text)) = True Then oPage.Name = inName.Text oPage.Content = DescriptionField.Text oPage.MenuName = inMenuName.Text If chkShowInBottomMenu.Checked = True Then oPage.ShowInBottomMenu = 1 Else oPage.ShowInBottomMenu = 0 End If If oPage.Update() = True Then Response.Redirect("content_custompages.aspx", True) Else msg.ShowError("Error While Saving Page") End If Else msg.ShowError("Error While Saving Page") End If Catch Ex As Exception msg.ShowException(Ex) End Try End Sub Sub LoadMenuImage() ButtonAnim.Text = "" msg.Clear() MenuButton.Visible = True Dim sURL As String = Content.CustomPage.GetCustomPageImageURL(inEditID.Text) If sURL.Trim.Length() > 0 Then sURL = "../" & sURL MenuButton.ImageUrl = sURL Else sURL = "../images/NoImageAvailable.gif" End If Dim sType As String = sURL.Substring(sURL.Length - 3, 3).ToLower If sType = "swf" Then MenuButton.Visible = False ButtonAnim.Text = ImageHelper.GetSWFTag(sURL, 175, 50) End If If sType = "svg" Then MenuButton.Visible = False ButtonAnim.Text = ImageHelper.GetSVGTag(sURL, 175, 50) End If End Sub Private Sub RemoveButton_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles RemoveButton.Click Content.CustomPage.DeleteCustomPageImage(inEditID.Text) LoadMenuImage() End Sub Private Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnUpload.Click Try ' Check File Extension Dim sFile As String sFile = inImageURL.PostedFile.FileName If sFile.Length < 1 Then msg.ShowWarning("Please enter a file name first to upload an image.") Else Dim iStart As Integer iStart = sFile.Length() - 4 Dim sExtension sExtension = sFile.Substring(iStart, 4) If CheckExtension(sExtension) = True Then Content.CustomPage.DeleteCustomPageImage(inEditID.Text) Dim sUploadPath As String sUploadPath = Request.PhysicalApplicationPath & "images\" sUploadPath += "CustomMenu" & inEditID.Text.Trim & sExtension.ToLower inImageURL.PostedFile.SaveAs(sUploadPath) LoadMenuImage() Else msg.ShowError(GetCheckExtensionError()) End If End If Catch Ex As Exception msg.ShowException(Ex) End Try End Sub Public Function CheckExtension(ByVal sExt As String) As Boolean Dim result As Boolean = False If sExt.ToLower = ".jpg" Then result = True End If If sExt.ToLower = ".gif" Then result = True End If If sExt.ToLower = ".png" Then result = True End If If sExt.ToLower = ".swf" Then result = True End If If sExt.ToLower = ".svg" Then result = True End If Return result End Function Public Function GetCheckExtensionError() As String Return "Images must be .jpg .gif .swf .svg or .png" End Function End Class