Option Explicit On 
Option Strict On
Option Compare Text

Imports System.Data.SqlClient

Public Class ViewChildPageContacts
	Inherits System.Web.UI.Page
	Protected WithEvents daContactLinks As System.Data.SqlClient.SqlDataAdapter
	Protected WithEvents DsContactLinks1 As AllSaints.dsContactLinks
	Protected WithEvents Conn As System.Data.SqlClient.SqlConnection
	Protected WithEvents cmdCL_Select As System.Data.SqlClient.SqlCommand
	Protected WithEvents cmdCL_Update As System.Data.SqlClient.SqlCommand
	Protected WithEvents dlSubPages As System.Web.UI.WebControls.DataList
	Protected WithEvents daChildPageLinks As System.Data.SqlClient.SqlDataAdapter
	Protected WithEvents cmdCPL_Select As System.Data.SqlClient.SqlCommand
	Protected WithEvents daViewPage As System.Data.SqlClient.SqlDataAdapter
	Protected WithEvents cmdVP_Select As System.Data.SqlClient.SqlCommand
	Protected WithEvents daViewChildPages As System.Data.SqlClient.SqlDataAdapter
	Protected WithEvents cmdVCP_Select As System.Data.SqlClient.SqlCommand
	Protected WithEvents daParentPage As System.Data.SqlClient.SqlDataAdapter
	Protected WithEvents cmdPP_Select As System.Data.SqlClient.SqlCommand
	Protected WithEvents DsViewChildPages1 As AllSaints.dsViewChildPages
	Protected WithEvents DsViewPage1 As AllSaints.dsViewPage
	Protected WithEvents DsParentPage1 As AllSaints.dsParentPage
	Protected WithEvents DsChildPageLinks1 As AllSaints.dsChildPageLinks
	Protected WithEvents txtPageName As System.Web.UI.WebControls.TextBox
	Protected WithEvents cmdCL_Delete As System.Data.SqlClient.SqlCommand
	Protected WithEvents daRelatedContacts As System.Data.SqlClient.SqlDataAdapter
	Protected WithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
	Protected WithEvents SqlInsertCommand1 As System.Data.SqlClient.SqlCommand
	Protected WithEvents SqlUpdateCommand1 As System.Data.SqlClient.SqlCommand
	Protected WithEvents SqlDeleteCommand1 As System.Data.SqlClient.SqlCommand
	Protected WithEvents DsGetRelatedContacts1 As AllSaints.dsGetRelatedContacts
	Protected WithEvents btnTopPicUpdate As System.Web.UI.WebControls.Button
	Protected WithEvents TopPanel As System.Web.UI.WebControls.Panel
	Protected WithEvents TopPicture As System.Web.UI.HtmlControls.HtmlInputFile
	Protected WithEvents pnlPageHeading As System.Web.UI.WebControls.Panel
	Protected WithEvents txtPageHeading As System.Web.UI.WebControls.TextBox
	Protected WithEvents pnlPageBodyLeft As System.Web.UI.WebControls.Panel
	Protected WithEvents RightPanel As System.Web.UI.WebControls.Panel
	Protected WithEvents imgRight As System.Web.UI.WebControls.Image
	Protected WithEvents txtImageDesc As System.Web.UI.WebControls.TextBox
	Protected WithEvents btnRightPicUpdate As System.Web.UI.WebControls.Button
	Protected WithEvents RightPicture As System.Web.UI.HtmlControls.HtmlInputFile
	Protected WithEvents DataGrid2 As System.Web.UI.WebControls.DataGrid
	Protected WithEvents btnUpdate As System.Web.UI.WebControls.Button
	Protected WithEvents lblPageID As System.Web.UI.WebControls.Label
	Protected WithEvents DG_RelatedLinks As System.Web.UI.WebControls.DataGrid
	Protected WithEvents DG_RelatedContacts As System.Web.UI.WebControls.DataGrid
	Protected WithEvents AddRelContact1 As AllSaints.AddRelatedContact
	Protected WithEvents pnlLinks As System.Web.UI.WebControls.Panel
	Protected WithEvents pnlContacts As System.Web.UI.WebControls.Panel
	Protected WithEvents imgTop As System.Web.UI.WebControls.Image
	Protected WithEvents lnkTopPicRemove As System.Web.UI.WebControls.LinkButton
	Protected WithEvents lnkRightPicRemove As System.Web.UI.WebControls.LinkButton
	Protected WithEvents EWE1 As EasyWebEditorControl.EasyWebEdit
	Protected WithEvents lblPageHeading As System.Web.UI.WebControls.Label
	Protected WithEvents AddRelLinks1 As AllSaints.AddRelatedLinks

#Region " Web Form Designer Generated Code "

	'This call is required by the Web Form Designer.
	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
		Me.daContactLinks = New System.Data.SqlClient.SqlDataAdapter()
		Me.cmdCL_Delete = New System.Data.SqlClient.SqlCommand()
		Me.Conn = New System.Data.SqlClient.SqlConnection()
		Me.cmdCL_Select = New System.Data.SqlClient.SqlCommand()
		Me.cmdCL_Update = New System.Data.SqlClient.SqlCommand()
		Me.DsContactLinks1 = New AllSaints.dsContactLinks()
		Me.daChildPageLinks = New System.Data.SqlClient.SqlDataAdapter()
		Me.cmdCPL_Select = New System.Data.SqlClient.SqlCommand()
		Me.daViewPage = New System.Data.SqlClient.SqlDataAdapter()
		Me.cmdVP_Select = New System.Data.SqlClient.SqlCommand()
		Me.daViewChildPages = New System.Data.SqlClient.SqlDataAdapter()
		Me.cmdVCP_Select = New System.Data.SqlClient.SqlCommand()
		Me.daParentPage = New System.Data.SqlClient.SqlDataAdapter()
		Me.cmdPP_Select = New System.Data.SqlClient.SqlCommand()
		Me.DsViewChildPages1 = New AllSaints.dsViewChildPages()
		Me.DsViewPage1 = New AllSaints.dsViewPage()
		Me.DsParentPage1 = New AllSaints.dsParentPage()
		Me.DsChildPageLinks1 = New AllSaints.dsChildPageLinks()
		Me.daRelatedContacts = New System.Data.SqlClient.SqlDataAdapter()
		Me.SqlDeleteCommand1 = New System.Data.SqlClient.SqlCommand()
		Me.SqlInsertCommand1 = New System.Data.SqlClient.SqlCommand()
		Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand()
		Me.SqlUpdateCommand1 = New System.Data.SqlClient.SqlCommand()
		Me.DsGetRelatedContacts1 = New AllSaints.dsGetRelatedContacts()
		CType(Me.DsContactLinks1, System.ComponentModel.ISupportInitialize).BeginInit()
		CType(Me.DsViewChildPages1, System.ComponentModel.ISupportInitialize).BeginInit()
		CType(Me.DsViewPage1, System.ComponentModel.ISupportInitialize).BeginInit()
		CType(Me.DsParentPage1, System.ComponentModel.ISupportInitialize).BeginInit()
		CType(Me.DsChildPageLinks1, System.ComponentModel.ISupportInitialize).BeginInit()
		CType(Me.DsGetRelatedContacts1, System.ComponentModel.ISupportInitialize).BeginInit()
		'
		'daContactLinks
		'
		Me.daContactLinks.DeleteCommand = Me.cmdCL_Delete
		Me.daContactLinks.SelectCommand = Me.cmdCL_Select
		Me.daContactLinks.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "cmdCL_Select", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("ID", "ID"), New System.Data.Common.DataColumnMapping("Page_ID", "Page_ID"), New System.Data.Common.DataColumnMapping("LinkName", "LinkName"), New System.Data.Common.DataColumnMapping("LinkURL", "LinkURL"), New System.Data.Common.DataColumnMapping("LinkPic", "LinkPic")})})
		Me.daContactLinks.UpdateCommand = Me.cmdCL_Update
		'
		'cmdCL_Delete
		'
		Me.cmdCL_Delete.CommandText = "[cmdCL_Delete]"
		Me.cmdCL_Delete.CommandType = System.Data.CommandType.StoredProcedure
		Me.cmdCL_Delete.Connection = Me.Conn
		Me.cmdCL_Delete.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
		Me.cmdCL_Delete.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
		'
		'Conn
		'
		Me.Conn.ConnectionString = "data source=localhost;initial catalog=allsaints;persist security info=False;user " & _
		"id=sa;workstation id=GALAXY;packet size=4096"
		'
		'cmdCL_Select
		'
		Me.cmdCL_Select.CommandText = "[cmdCL_Select]"
		Me.cmdCL_Select.CommandType = System.Data.CommandType.StoredProcedure
		Me.cmdCL_Select.Connection = Me.Conn
		Me.cmdCL_Select.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
		Me.cmdCL_Select.Parameters.Add(New System.Data.SqlClient.SqlParameter("@PageID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
		'
		'cmdCL_Update
		'
		Me.cmdCL_Update.CommandText = "[cmdCL_Update]"
		Me.cmdCL_Update.CommandType = System.Data.CommandType.StoredProcedure
		Me.cmdCL_Update.Connection = Me.Conn
		Me.cmdCL_Update.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
		Me.cmdCL_Update.Parameters.Add(New System.Data.SqlClient.SqlParameter("@LinkName", System.Data.SqlDbType.VarChar, 255, "LinkName"))
		Me.cmdCL_Update.Parameters.Add(New System.Data.SqlClient.SqlParameter("@LinkURL", System.Data.SqlDbType.VarChar, 255, "LinkURL"))
		Me.cmdCL_Update.Parameters.Add(New System.Data.SqlClient.SqlParameter("@LinkPic", System.Data.SqlDbType.VarChar, 255, "LinkPic"))
		Me.cmdCL_Update.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(10, Byte), CType(0, Byte), "ID", System.Data.DataRowVersion.Current, Nothing))
		'
		'DsContactLinks1
		'
		Me.DsContactLinks1.DataSetName = "dsContactLinks"
		Me.DsContactLinks1.Locale = New System.Globalization.CultureInfo("en-US")
		Me.DsContactLinks1.Namespace = "http://www.tempuri.org/dsContactLinks.xsd"
		'
		'daChildPageLinks
		'
		Me.daChildPageLinks.SelectCommand = Me.cmdCPL_Select
		Me.daChildPageLinks.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "GetChildPages", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("ID", "ID"), New System.Data.Common.DataColumnMapping("PageName", "PageName"), New System.Data.Common.DataColumnMapping("Body", "Body"), New System.Data.Common.DataColumnMapping("BodyHeading", "BodyHeading"), New System.Data.Common.DataColumnMapping("TopPicture", "TopPicture"), New System.Data.Common.DataColumnMapping("RightPicture", "RightPicture"), New System.Data.Common.DataColumnMapping("ParentID", "ParentID")})})
		'
		'cmdCPL_Select
		'
		Me.cmdCPL_Select.CommandText = "[GetChildPages]"
		Me.cmdCPL_Select.CommandType = System.Data.CommandType.StoredProcedure
		Me.cmdCPL_Select.Connection = Me.Conn
		Me.cmdCPL_Select.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
		Me.cmdCPL_Select.Parameters.Add(New System.Data.SqlClient.SqlParameter("@PageID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
		'
		'daViewPage
		'
		Me.daViewPage.SelectCommand = Me.cmdVP_Select
		Me.daViewPage.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "GetPageInfo", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("ID", "ID"), New System.Data.Common.DataColumnMapping("PageName", "PageName"), New System.Data.Common.DataColumnMapping("Body", "Body"), New System.Data.Common.DataColumnMapping("BodyHeading", "BodyHeading"), New System.Data.Common.DataColumnMapping("TopPicture", "TopPicture"), New System.Data.Common.DataColumnMapping("RightPicture", "RightPicture"), New System.Data.Common.DataColumnMapping("ParentID", "ParentID")})})
		'
		'cmdVP_Select
		'
		Me.cmdVP_Select.CommandText = "[GetPageInfo]"
		Me.cmdVP_Select.CommandType = System.Data.CommandType.StoredProcedure
		Me.cmdVP_Select.Connection = Me.Conn
		Me.cmdVP_Select.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
		Me.cmdVP_Select.Parameters.Add(New System.Data.SqlClient.SqlParameter("@PageID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
		'
		'daViewChildPages
		'
		Me.daViewChildPages.SelectCommand = Me.cmdVCP_Select
		Me.daViewChildPages.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "GetChildPages", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("ID", "ID"), New System.Data.Common.DataColumnMapping("PageName", "PageName"), New System.Data.Common.DataColumnMapping("Body", "Body"), New System.Data.Common.DataColumnMapping("BodyHeading", "BodyHeading"), New System.Data.Common.DataColumnMapping("TopPicture", "TopPicture"), New System.Data.Common.DataColumnMapping("RightPicture", "RightPicture"), New System.Data.Common.DataColumnMapping("ParentID", "ParentID")})})
		'
		'cmdVCP_Select
		'
		Me.cmdVCP_Select.CommandText = "[GetChildPages]"
		Me.cmdVCP_Select.CommandType = System.Data.CommandType.StoredProcedure
		Me.cmdVCP_Select.Connection = Me.Conn
		Me.cmdVCP_Select.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
		Me.cmdVCP_Select.Parameters.Add(New System.Data.SqlClient.SqlParameter("@PageID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
		'
		'daParentPage
		'
		Me.daParentPage.SelectCommand = Me.cmdPP_Select
		Me.daParentPage.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "GetPageInfo", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("ID", "ID"), New System.Data.Common.DataColumnMapping("PageName", "PageName"), New System.Data.Common.DataColumnMapping("Body", "Body"), New System.Data.Common.DataColumnMapping("BodyHeading", "BodyHeading"), New System.Data.Common.DataColumnMapping("TopPicture", "TopPicture"), New System.Data.Common.DataColumnMapping("RightPicture", "RightPicture"), New System.Data.Common.DataColumnMapping("ParentID", "ParentID")})})
		'
		'cmdPP_Select
		'
		Me.cmdPP_Select.CommandText = "[GetPageInfo]"
		Me.cmdPP_Select.CommandType = System.Data.CommandType.StoredProcedure
		Me.cmdPP_Select.Connection = Me.Conn
		Me.cmdPP_Select.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
		Me.cmdPP_Select.Parameters.Add(New System.Data.SqlClient.SqlParameter("@PageID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
		'
		'DsViewChildPages1
		'
		Me.DsViewChildPages1.DataSetName = "dsViewChildPages"
		Me.DsViewChildPages1.Locale = New System.Globalization.CultureInfo("en-US")
		Me.DsViewChildPages1.Namespace = "http://www.tempuri.org/dsViewChildPages.xsd"
		'
		'DsViewPage1
		'
		Me.DsViewPage1.DataSetName = "dsViewPage"
		Me.DsViewPage1.Locale = New System.Globalization.CultureInfo("en-US")
		Me.DsViewPage1.Namespace = "http://www.tempuri.org/dsViewPage.xsd"
		'
		'DsParentPage1
		'
		Me.DsParentPage1.DataSetName = "dsParentPage"
		Me.DsParentPage1.Locale = New System.Globalization.CultureInfo("en-US")
		Me.DsParentPage1.Namespace = "http://www.tempuri.org/dsParentPage.xsd"
		'
		'DsChildPageLinks1
		'
		Me.DsChildPageLinks1.DataSetName = "dsChildPageLinks"
		Me.DsChildPageLinks1.Locale = New System.Globalization.CultureInfo("en-US")
		Me.DsChildPageLinks1.Namespace = "http://www.tempuri.org/dsChildPageLinks.xsd"
		'
		'daRelatedContacts
		'
		Me.daRelatedContacts.DeleteCommand = Me.SqlDeleteCommand1
		Me.daRelatedContacts.InsertCommand = Me.SqlInsertCommand1
		Me.daRelatedContacts.SelectCommand = Me.SqlSelectCommand1
		Me.daRelatedContacts.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "GetRelContacts", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("ID", "ID"), New System.Data.Common.DataColumnMapping("Page_ID", "Page_ID"), New System.Data.Common.DataColumnMapping("Heading", "Heading"), New System.Data.Common.DataColumnMapping("InfoText", "InfoText")})})
		Me.daRelatedContacts.UpdateCommand = Me.SqlUpdateCommand1
		'
		'SqlDeleteCommand1
		'
		Me.SqlDeleteCommand1.CommandText = "[DelRelContacts]"
		Me.SqlDeleteCommand1.CommandType = System.Data.CommandType.StoredProcedure
		Me.SqlDeleteCommand1.Connection = Me.Conn
		Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
		Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ContactID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(10, Byte), CType(0, Byte), "ID", System.Data.DataRowVersion.Original, Nothing))
		'
		'SqlInsertCommand1
		'
		Me.SqlInsertCommand1.CommandText = "[InsRelContacts]"
		Me.SqlInsertCommand1.CommandType = System.Data.CommandType.StoredProcedure
		Me.SqlInsertCommand1.Connection = Me.Conn
		Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
		Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@PageID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(10, Byte), CType(0, Byte), "Page_ID", System.Data.DataRowVersion.Current, Nothing))
		Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Heading", System.Data.SqlDbType.VarChar, 255, "Heading"))
		Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@InfoText", System.Data.SqlDbType.VarChar, 255, "InfoText"))
		'
		'SqlSelectCommand1
		'
		Me.SqlSelectCommand1.CommandText = "[GetRelContacts]"
		Me.SqlSelectCommand1.CommandType = System.Data.CommandType.StoredProcedure
		Me.SqlSelectCommand1.Connection = Me.Conn
		Me.SqlSelectCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
		Me.SqlSelectCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@PageID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
		'
		'SqlUpdateCommand1
		'
		Me.SqlUpdateCommand1.CommandText = "[SetRelContacts]"
		Me.SqlUpdateCommand1.CommandType = System.Data.CommandType.StoredProcedure
		Me.SqlUpdateCommand1.Connection = Me.Conn
		Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
		Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ContactID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(10, Byte), CType(0, Byte), "ID", System.Data.DataRowVersion.Current, Nothing))
		Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Heading", System.Data.SqlDbType.VarChar, 255, "Heading"))
		Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@InfoText", System.Data.SqlDbType.VarChar, 255, "InfoText"))
		'
		'DsGetRelatedContacts1
		'
		Me.DsGetRelatedContacts1.DataSetName = "dsGetRelatedContacts"
		Me.DsGetRelatedContacts1.Locale = New System.Globalization.CultureInfo("en-US")
		Me.DsGetRelatedContacts1.Namespace = "http://www.tempuri.org/dsGetRelatedContacts.xsd"
		CType(Me.DsContactLinks1, System.ComponentModel.ISupportInitialize).EndInit()
		CType(Me.DsViewChildPages1, System.ComponentModel.ISupportInitialize).EndInit()
		CType(Me.DsViewPage1, System.ComponentModel.ISupportInitialize).EndInit()
		CType(Me.DsParentPage1, System.ComponentModel.ISupportInitialize).EndInit()
		CType(Me.DsChildPageLinks1, System.ComponentModel.ISupportInitialize).EndInit()
		CType(Me.DsGetRelatedContacts1, System.ComponentModel.ISupportInitialize).EndInit()

	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

	Private Sub GetData()

		If CType(Request("Level"), Integer) = 2 Then
			'get the parent id of this child page
			Dim cmd As New SqlCommand("Select ParentID from as_Pages where ID=" & CType(Request("ID"), Integer), Conn)

			If Conn.State = ConnectionState.Closed Then
				Dim sConStr As String = ConfigurationSettings.AppSettings("sConnection")
				Try
					Conn.ConnectionString = sConStr
				Catch ex As Exception
				End Try
				Conn.Open()
			End If

			Dim intParentID As Integer = CType(cmd.ExecuteScalar(), Integer)


			'get the second level parent id of this child page
			cmd = New SqlCommand("Select ParentID from as_Pages where ID=" & CType(intParentID, Integer), Conn)
			If Conn.State = ConnectionState.Closed Then
				Dim sConStr As String = ConfigurationSettings.AppSettings("sConnection")
				Try
					Conn.ConnectionString = sConStr
				Catch ex As Exception
				End Try
				Conn.Open()
			End If
			intParentID = CType(cmd.ExecuteScalar(), Integer)

			'get the parent's child pages to be binded against dlSubPages 'intParentID
			daViewChildPages.SelectCommand.Parameters("@PageID").Value = intParentID
			daViewChildPages.Fill(DsViewChildPages1)

			'get the first level parent id of this child page
			cmd = New SqlCommand("Select ParentID from as_Pages where ID=" & intParentID, Conn)
			If Conn.State = ConnectionState.Closed Then
				Dim sConStr As String = ConfigurationSettings.AppSettings("sConnection")
				Try
					Conn.ConnectionString = sConStr
				Catch ex As Exception
				End Try
				Conn.Open()
			End If
			intParentID = CType(cmd.ExecuteScalar(), Integer)

			'???
			'cmd = New SqlCommand("Select ParentID from as_Pages where ID=" & CType(Request("ID"), Integer), Conn)
			'If Conn.State = ConnectionState.Closed Then Conn.Open()
			'intParentID = CType(cmd.ExecuteScalar(), Integer)

			'get the details about this page's parent's sublings
			daChildPageLinks.SelectCommand.Parameters("@PageID").Value = intParentID
			daChildPageLinks.Fill(DsChildPageLinks1)


			'get the first level parent id of this child page
			'cmd = New SqlCommand("Select ParentID from as_Pages where ID=" & CType(Request("ID"), Integer), Conn)
			'If Conn.State = ConnectionState.Closed Then Conn.Open()
			'intParentID = CType(cmd.ExecuteScalar(), Integer)

			'get the contents links of this child page
			daContactLinks.SelectCommand.Parameters("@PageID").Value = CType(CType(Request("ID"), Integer), Integer)
			daContactLinks.Fill(DsContactLinks1)


			'get the details about this page
			daViewPage.SelectCommand.Parameters("@PageID").Value = CType(Request("ID"), Integer)
			daViewPage.Fill(DsViewPage1)

		ElseIf (CType(Request("Level"), Integer) = 1) Then
			'get the second level parent id of this child page
			Dim cmd As New SqlCommand("Select ParentID from as_Pages where ID=" & CType(Request("ID"), Integer), Conn)
			If Conn.State = ConnectionState.Closed Then
				Dim sConStr As String = ConfigurationSettings.AppSettings("sConnection")
				Try
					Conn.ConnectionString = sConStr
				Catch ex As Exception
				End Try
				Conn.Open()
			End If
			Dim intParentID As Integer = CType(cmd.ExecuteScalar(), Integer)

			'get the parent's child pages to be binded against dlSubPages 'intParentID
			daViewChildPages.SelectCommand.Parameters("@PageID").Value = intParentID
			daViewChildPages.Fill(DsViewChildPages1)

			'get the first level parent id of this child page
			cmd = New SqlCommand("Select ParentID from as_Pages where ID=" & intParentID, Conn)
			If Conn.State = ConnectionState.Closed Then
				Dim sConStr As String = ConfigurationSettings.AppSettings("sConnection")
				Try
					Conn.ConnectionString = sConStr
				Catch ex As Exception
				End Try
				Conn.Open()
			End If
			intParentID = CType(cmd.ExecuteScalar(), Integer)

			'get the details about this page's parent's sublings
			daChildPageLinks.SelectCommand.Parameters("@PageID").Value = intParentID
			daChildPageLinks.Fill(DsChildPageLinks1)


			'get the first level parent id of this child page
			'cmd = New SqlCommand("Select ParentID from as_Pages where ID=" & CType(Request("ID"), Integer), Conn)
			'If Conn.State = ConnectionState.Closed Then Conn.Open()
			'intParentID = CType(cmd.ExecuteScalar(), Integer)

			'get the contents links of this child page
			daContactLinks.SelectCommand.Parameters("@PageID").Value = CType(CType(Request("ID"), Integer), Integer)
			daContactLinks.Fill(DsContactLinks1)


			'get the details about this page
			daViewPage.SelectCommand.Parameters("@PageID").Value = CType(Request("ID"), Integer)
			daViewPage.Fill(DsViewPage1)

		Else
			'get the details about this page
			daViewPage.SelectCommand.Parameters("@PageID").Value = CType(Request("ID"), Integer)
			daViewPage.Fill(DsViewPage1)

			'get the second level parent id of this child page
			Dim cmd As New SqlCommand("Select ParentID from as_Pages where ID=" & CType(Request("ID"), Integer), Conn)
			If Conn.State = ConnectionState.Closed Then
				Dim sConStr As String = ConfigurationSettings.AppSettings("sConnection")
				Try
					Conn.ConnectionString = sConStr
				Catch ex As Exception
				End Try
				Conn.Open()
			End If
			Dim intParentID As Integer = CType(cmd.ExecuteScalar(), Integer)

			'get the details about this child page
			daChildPageLinks.SelectCommand.Parameters("@PageID").Value = intParentID
			daChildPageLinks.Fill(DsChildPageLinks1)

			'get the parent's child pages to be binded against dlSubPages 'intParentID
			daViewChildPages.SelectCommand.Parameters("@PageID").Value = CType(Request("ID"), Integer)
			daViewChildPages.Fill(DsViewChildPages1)

			'get the contents links of this child page
			daContactLinks.SelectCommand.Parameters("@PageID").Value = CType(Request("ID"), Integer)
			daContactLinks.Fill(DsContactLinks1)

		End If
		Page.DataBind()

	End Sub

	Private Sub GetContactData()
		daRelatedContacts.SelectCommand.Parameters("@PageID").Value = CType(Request("ID"), Integer)
		daRelatedContacts.Fill(DsGetRelatedContacts1)
	End Sub

#End Region

	Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		Dim sConStr As String = ConfigurationSettings.AppSettings("sConnection")
		Try
			Conn.ConnectionString = sConStr
		Catch ex As Exception

		End Try
		'If Conn.State <> ConnectionState.Open Then Conn.ConnectionString = sConStr

		AddRelContact1.PageID = CType(Request("ID"), Integer)
		AddRelLinks1.PageID = CType(Request("ID"), Integer)
		lnkRightPicRemove.Attributes.Add("onclick", "return confirm('Are you sure ?');")
		lnkTopPicRemove.Attributes.Add("onclick", "return confirm('Are you sure ?');")

		If Not Page.IsPostBack Then
			Call GetContactData()
			Call GetData()

			If CType(Request("Level"), Integer) <> 0 Then
				TopPanel.Visible = True
				RightPanel.Visible = True
				pnlPageBodyLeft.Visible = True
				pnlPageHeading.Visible = True
				pnlContacts.Visible = True
				pnlLinks.Visible = True
				lblPageHeading.Visible = True
				EWE1.Visible = True
				EWE1.HTMLValue = CType(DsViewPage1.GetPageInfo.Rows.Item(0).Item("Body"), String)
			End If


		End If


	End Sub

	Private Sub dlSubPages_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dlSubPages.ItemCommand

		If e.CommandName = "ParentPageName" Then
			Response.Redirect("ViewChildPageContacts.aspx?ID=" & CType(e.CommandArgument, Integer))
		End If

	End Sub

	Private Sub dlSubPages_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles dlSubPages.ItemCreated
		Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)

		If (Not drv Is Nothing) And (DsChildPageLinks1.Tables(0).Rows.Count > 0) Then
			If (CType(drv.Item("id"), Integer) = CType(Request("id"), Integer)) Then
				Dim li As LinkButton = CType(e.Item.Controls(1), LinkButton)
				With li
					.CssClass = "nav1linkon"
				End With
			End If
		End If
	End Sub

	'****************************************************************************************************
	Private Sub DataGrid2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid2.SelectedIndexChanged
	End Sub

	Private Sub DataGrid2_ItemCreated(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid2.ItemCreated
		'confirm that this occres for the level 1 or 2
		If CType(Request("Level"), Integer) >= 1 Then
			'if this is not the header or footer item then 
			If e.Item.ItemIndex <> -1 Then
				'get the data row view {database link to data source} for this item {row }
				Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)
				Dim cmd As New SqlCommand()

				Dim itemID As Integer = CType(Request("ID"), Integer)				'current page id posted

				'if this is the second level then get the parent ID to match with the row that is  being created
				If CType(Request("Level"), Integer) = 2 Then
					cmd = New SqlCommand("Select ParentID from as_Pages where ID=" & CType(Request("ID"), Integer), Conn)
					If Conn.State = ConnectionState.Closed Then
						Dim sConStr As String = ConfigurationSettings.AppSettings("sConnection")
						Try
							Conn.ConnectionString = sConStr
						Catch ex As Exception
						End Try
						Conn.Open()
					End If
					itemID = CType(cmd.ExecuteScalar(), Integer)
				End If

				'If drv{databse link to datasource for this item row} of this row exits then
				If (Not drv Is Nothing) AndAlso itemID = CType(drv.Item(0), Integer) Then
					Dim l As HyperLink = CType(e.Item.Cells(0).Controls(0), HyperLink)
					l.ForeColor = Color.Gray					  '.CssClass = "nav2linkon"

					'get the child pages and display their links for editing {nav3...}
					With cmd
						.CommandText = "Select * from as_Pages where ParentID=" & CType(drv.Item(0), Integer)
						.CommandType = CommandType.Text
						.Connection = Conn
						If Conn.State = ConnectionState.Closed Then
							Dim sConStr As String = ConfigurationSettings.AppSettings("sConnection")
							Try
								Conn.ConnectionString = sConStr
							Catch ex As Exception
							End Try
							Conn.Open()
						End If
						Dim rdr As SqlDataReader = .ExecuteReader()

						'if found any then loop through each and display in table rows
						If Not rdr Is Nothing Then
							Dim c As TableCell = CType(e.Item.Controls(0), TableCell)
							Dim ph As PlaceHolder = New PlaceHolder()
							ph.Controls.Add(New LiteralControl("<Table border='0' align='right' width='130'>"))
							Dim sCss As String = "nav3linkoff"
							While rdr.Read

								If (CType(Request("Level"), Integer) = 2) And (CType(Request("ID"), Integer) = CType(rdr.Item("ID"), Integer)) Then sCss = "nav3linkon" Else sCss = "nav3linkoff"

								ph.Controls.Add(New LiteralControl("<TR><TD><a href='ViewChildPageContacts.aspx?Level=2&ID=" & CType(rdr.Item("ID"), Integer) & "' class='" & sCss & "'>" & CType(rdr.Item("PageName"), String) & "</a></TD></TR>"))
							End While
							rdr.Close()
							ph.Controls.Add(New LiteralControl("</Table>"))
							c.Controls.Add(ph)
						End If
					End With
				End If
			End If
		Else
			'if this is not the header or footer item then 
			If e.Item.ItemType = ListItemType.Item Then
				'get the data row view {database link to data source} for this item {row }
				Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)
				If Not drv Is Nothing Then
					'set the calender links to go to calender page to set Events
					Select Case CType(drv.Item(0), Integer)
						Case 249, 250, 261, 318						'Church,School, Facilities, Special Calenders
							Dim hlCol As HyperLinkColumn = CType(DataGrid2.Columns(0), HyperLinkColumn)
							hlCol.DataNavigateUrlFormatString = "ViewCalender.aspx?Level=1&ID={0}"
					End Select
				End If
			End If
			End If
	End Sub


	Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
		If CType(lblPageID.Text, Integer) <> 0 Then
			Dim cmd As New SqlCommand()
			With cmd
				.CommandText = "Update as_Pages set PageName=@PageName,Body=@BodyHTML,BodyHeading=@BodyHeading where(ID=@PageID) "
				.Parameters.Add("@PageName", Trim(txtPageName.Text))
				.Parameters.Add("@BodyHTML", Trim(EWE1.HTMLValue))
				.Parameters.Add("@BodyHeading", Trim(txtPageHeading.Text))
				.Parameters.Add("@PageID", CType(lblPageID.Text, Integer))
				.CommandType = CommandType.Text
				.Connection = Conn
				If Conn.State = ConnectionState.Closed Then
					Dim sConStr As String = ConfigurationSettings.AppSettings("sConnection")
					Try
						Conn.ConnectionString = sConStr
					Catch ex As Exception
					End Try
					Conn.Open()
				End If
				.ExecuteNonQuery()
			End With
		End If

		'bind all the page with new data from server
		Call GetContactData()
		Call GetData()
	End Sub


#Region "Related Contacts Data Grid ***************************************************"
	'******************************************************************************
	Private Sub DG_RelatedContacts_ItemCreated(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DG_RelatedContacts.ItemCreated
		If (e.Item.ItemType = ListItemType.Header) Then
			'Dim lb As LinkButton = New LinkButton()
			'With lb
			'	.Text = "Add New"
			'	.CommandArgument = ""
			'	.CommandName = "ADD"
			'	.CssClass = "nav1linkon"
			'	.ID = "lnkAddNewContact"
			'	.Visible = True
			'	.Attributes.Add("onClick", "window.open('AddRelatedContact.aspx?ID=" & Request("ID") & "','','width=400,height=200, menu=no');return false;")
			'End With
			'e.Item.Cells(0).Controls.Add(lb)
		ElseIf e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.EditItem Then
			Dim lb As LinkButton = CType(e.Item.Cells(3).Controls(0), LinkButton)
			lb.Attributes.Add("onClick", "return confirm('Are you you sure to delete this contact?');")

		End If

	End Sub
	Private Sub DG_RelatedContacts_CancelCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DG_RelatedContacts.CancelCommand
		With DG_RelatedContacts
			.Columns(3).Visible = True
			.EditItemIndex = -1
		End With
		Call GetContactData()
		Call GetData()

	End Sub
	Private Sub DG_RelatedContacts_EditCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DG_RelatedContacts.EditCommand
		With DG_RelatedContacts
			.Columns(3).Visible = False
			.EditItemIndex = e.Item.ItemIndex
		End With
		Call GetContactData()
		Call GetData()
	End Sub
	Private Sub DG_RelatedContacts_DeleteCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DG_RelatedContacts.DeleteCommand

		With daRelatedContacts.DeleteCommand
			.Parameters("@ContactID").Value = CType(DG_RelatedContacts.DataKeys(e.Item.ItemIndex), Integer)
			If Conn.State = ConnectionState.Closed Then
				Dim sConStr As String = ConfigurationSettings.AppSettings("sConnection")
				Try
					Conn.ConnectionString = sConStr
				Catch ex As Exception
				End Try
				Conn.Open()
			End If
			.ExecuteNonQuery()
		End With

		With DG_RelatedContacts
			.Columns(3).Visible = True
			.EditItemIndex = -1
		End With
		Call GetContactData()
		Call GetData()

	End Sub
	Private Sub DG_RelatedContacts_UpdateCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DG_RelatedContacts.UpdateCommand

		Dim tlnk As TextBox = CType(e.Item.Cells(0).Controls(0), TextBox)
		Dim tadd As TextBox = CType(e.Item.Cells(1).Controls(0), TextBox)
		With daRelatedContacts.UpdateCommand
			.Parameters("@ContactID").Value = CType(DG_RelatedContacts.DataKeys(e.Item.ItemIndex), Integer)
			.Parameters("@Heading").Value = Trim(tlnk.Text)
			.Parameters("@InfoText").Value = Trim(tadd.Text)
			If Conn.State = ConnectionState.Closed Then
				Dim sConStr As String = ConfigurationSettings.AppSettings("sConnection")
				Try
					Conn.ConnectionString = sConStr
				Catch ex As Exception
				End Try
				Conn.Open()
			End If
			.ExecuteNonQuery()
		End With

		With DG_RelatedContacts
			.Columns(3).Visible = True
			.EditItemIndex = -1
		End With
		Call GetContactData()
		Call GetData()

	End Sub
#End Region

#Region "Related Links Data Grid ******************************************************"
	'******************************************************************************
	Private Sub DG_RelatedLinks_UpdateCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DG_RelatedLinks.UpdateCommand

		Dim tlnk As TextBox = CType(e.Item.Cells(0).Controls(0), TextBox)
		Dim tadd As TextBox = CType(e.Item.Cells(1).Controls(0), TextBox)
		With daContactLinks.UpdateCommand
			.Parameters("@LinkName").Value = Trim(tlnk.Text)
			.Parameters("@LinkURL").Value = Trim(tadd.Text)
			.Parameters("@LinkPic").Value = ""
			.Parameters("@Original_ID").Value = CType(DG_RelatedLinks.DataKeys(e.Item.ItemIndex), Integer)
			If Conn.State = ConnectionState.Closed Then
				Dim sConStr As String = ConfigurationSettings.AppSettings("sConnection")
				Try
					Conn.ConnectionString = sConStr
				Catch ex As Exception
				End Try
				Conn.Open()
			End If
			.ExecuteNonQuery()
		End With

		With DG_RelatedLinks
			.Columns(3).Visible = True
			.EditItemIndex = -1
		End With

		Call GetContactData()
		Call GetData()

	End Sub
	Private Sub DG_RelatedLinks_CancelCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DG_RelatedLinks.CancelCommand
		With DG_RelatedLinks
			.Columns(3).Visible = True
			.EditItemIndex = -1
		End With
		Call GetContactData()
		Call GetData()
	End Sub
	Private Sub DG_RelatedLinks_DeleteCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DG_RelatedLinks.DeleteCommand
		With daContactLinks.DeleteCommand
			.Parameters("@Original_ID").Value = CType(DG_RelatedLinks.DataKeys(e.Item.ItemIndex), Integer)
			If Conn.State = ConnectionState.Closed Then
				Dim sConStr As String = ConfigurationSettings.AppSettings("sConnection")
				Try
					Conn.ConnectionString = sConStr
				Catch ex As Exception
				End Try
				Conn.Open()
			End If
			.ExecuteNonQuery()
		End With

		With DG_RelatedLinks
			.EditItemIndex = -1
		End With
		Call GetContactData()
		Call GetData()
	End Sub
	Private Sub DG_RelatedLinks_EditCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DG_RelatedLinks.EditCommand
		With DG_RelatedLinks
			.Columns(3).Visible = False
			.EditItemIndex = e.Item.ItemIndex
		End With
		Call GetContactData()
		Call GetData()
	End Sub
	Private Sub DG_RelatedLinks_ItemCreated(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DG_RelatedLinks.ItemCreated
		If (e.Item.ItemType = ListItemType.Header) Then
			'Dim lb As LinkButton = New LinkButton()
			'With lb
			'	.Text = "Add New"
			'	.CommandArgument = ""
			'	.CommandName = "ADD"
			'	.CssClass = "nav1linkon"
			'	.ID = "lnkAddNewContact"
			'	.Visible = True
			'	.Attributes.Add("onClick", "window.open('AddRelatedLinks.aspx?ID=" & Request("ID") & "','','width=400,height=200, menu=no');return false;")
			'End With
			'e.Item.Cells(0).Controls.Add(lb)
		ElseIf e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.EditItem Then
			Dim lb As LinkButton = CType(e.Item.Cells(3).Controls(0), LinkButton)
			lb.Attributes.Add("onClick", "return confirm('Are you you sure to delete this link?');")
		End If
	End Sub
#End Region


	Private Sub btnTopPicUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTopPicUpdate.Click
		Dim cmd As New SqlCommand()

		With TopPicture.PostedFile
			If .FileName <> "" Then
				Select Case Trim(.ContentType.ToLower)

					Case "image/gif", "image/pjpg", "image/jpeg", "image/pjpeg", "image/jpg"
						Try
							Dim sFilename As String = System.IO.Path.GetExtension(.FileName)
							sFilename = "\contents\images\" & Trim(lblPageID.Text) & "top" & sFilename
							.SaveAs(Server.MapPath("..") & sFilename)

							With cmd
								.CommandText = "Update as_Pages Set TopPicture='." & sFilename & "' where ID=" & CType(Trim(lblPageID.Text), Integer)
								.CommandType = CommandType.Text
								.Connection = Conn
								If Conn.State = ConnectionState.Closed Then
									Dim sConStr As String = ConfigurationSettings.AppSettings("sConnection")
									Try
										Conn.ConnectionString = sConStr
									Catch ex As Exception
									End Try
									Conn.Open()
								End If
								.ExecuteNonQuery()
							End With

						Catch ex As Exception
							Response.Write(ex.ToString)

						End Try

					Case Else
						'nothing
				End Select
				'referesh the page data
				Call GetContactData()
				Call GetData()
			End If
		End With

	End Sub

	Private Sub btnRightPicUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRightPicUpdate.Click
		Dim cmd As New SqlCommand()

		With RightPicture.PostedFile
			If .FileName <> "" Then
				Select Case Trim(.ContentType.ToLower)

					Case "image/gif", "image/pjpg", "image/jpeg", "image/pjpeg", "image/jpg"
						Try
							Dim sFilename As String = System.IO.Path.GetExtension(.FileName)
							sFilename = "\contents\images\" & Trim(lblPageID.Text) & "right" & sFilename
							.SaveAs(Server.MapPath("..") & sFilename)

							With cmd
								.CommandText = "Update as_Pages Set  RightPicDesc='" & Replace(Trim(txtImageDesc.Text), "'", "''") & "' , RightPicture='." & sFilename & "' where ID=" & CType(Trim(lblPageID.Text), Integer)
								.CommandType = CommandType.Text
								.Connection = Conn
								If Conn.State = ConnectionState.Closed Then
									Dim sConStr As String = ConfigurationSettings.AppSettings("sConnection")
									Try
										Conn.ConnectionString = sConStr
									Catch ex As Exception
									End Try
									Conn.Open()
								End If
								.ExecuteNonQuery()
							End With

						Catch ex As Exception
							Response.Write(ex.ToString)

						End Try

					Case Else
						'nothing
				End Select

				'referesh the page data with latest one from db
				Call GetContactData()
				Call GetData()
			End If
		End With
	End Sub

	Private Sub imgTop_PreRender(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles imgTop.PreRender
		Dim img As System.Web.UI.WebControls.Image = CType(sender, System.Web.UI.WebControls.Image)
		If img.ImageUrl.Length > 0 Then
			img.ImageUrl = img.ImageUrl.Substring(2)
			img.ImageUrl = "..\" & img.ImageUrl
		Else
			img.ImageUrl = "..\contents\images\noimage.jpg"
		End If
	End Sub

	Private Sub imgRight_PreRender(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles imgRight.PreRender
		Dim img As System.Web.UI.WebControls.Image = CType(sender, System.Web.UI.WebControls.Image)
		If img.ImageUrl.Length > 0 Then
			img.ImageUrl = img.ImageUrl.Substring(2)
			img.ImageUrl = "..\" & img.ImageUrl
		Else
			img.ImageUrl = "..\contents\images\noimage.jpg"
		End If
	End Sub

	Private Sub AddRelContact1_ContactAdded() Handles AddRelContact1.ContactAdded
		'referesh the page data with latest one from db
		Call GetContactData()
		Call GetData()
	End Sub

	Private Sub AddRelLinks1_LinkAdded() Handles AddRelLinks1.LinkAdded
		'referesh the page data with latest one from db
		Call GetContactData()
		Call GetData()
	End Sub

	'****************************************************************************
	'	This will Remove Top Body Picture { right of Top Links }
	'****************************************************************************
	Private Sub lnkTopPicRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkTopPicRemove.Click
		Dim cmd As New SqlCommand()
		With cmd
			.CommandText = "Select TopPicture from as_Pages where ID=" & CType(Trim(lblPageID.Text), Integer)
			.CommandType = CommandType.Text
			.Connection = Conn
			If Conn.State = ConnectionState.Closed Then
				Dim sConStr As String = ConfigurationSettings.AppSettings("sConnection")
				Try
					Conn.ConnectionString = sConStr
				Catch ex As Exception
				End Try
				Conn.Open()
			End If
			Dim sFilename As String = CType(.ExecuteScalar, String)

			If sFilename.Length > 0 Then
				Try
					sFilename = sFilename.Substring(1)
					'System.IO.File.Delete(Server.MapPath("..") & sFilename)
				Catch ex As Exception
					'do nothing
				End Try
				.CommandText = "Update as_Pages Set TopPicture='' where ID=" & CType(Trim(lblPageID.Text), Integer)
				.CommandType = CommandType.Text
				.Connection = Conn
				If Conn.State = ConnectionState.Closed Then
					Dim sConStr As String = ConfigurationSettings.AppSettings("sConnection")
					Try
						Conn.ConnectionString = sConStr
					Catch ex As Exception
					End Try
					Conn.Open()
				End If
				.ExecuteNonQuery()

				'referesh the page data
				Call GetContactData()
				Call GetData()

			End If

		End With

	End Sub

	'****************************************************************************
	'	This will Remove Right Body Picture
	'****************************************************************************
	Private Sub lnkRightPicRemove_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkRightPicRemove.Click
		Dim cmd As New SqlCommand()
		With cmd

			.CommandText = "Select RightPicture from as_Pages where ID=" & CType(Trim(lblPageID.Text), Integer)
			.CommandType = CommandType.Text
			.Connection = Conn
			If Conn.State = ConnectionState.Closed Then
				Dim sConStr As String = ConfigurationSettings.AppSettings("sConnection")
				Try
					Conn.ConnectionString = sConStr
				Catch ex As Exception
				End Try
				Conn.Open()
			End If
			Dim sFilename As String = CType(.ExecuteScalar, String)

			If sFilename.Length > 0 Then
				Try
					sFilename = sFilename.Substring(1)
					'System.IO.File.Delete(Server.MapPath("..") & sFilename)
				Catch ex As Exception
					'do nothing
				End Try
				.CommandText = "Update as_Pages Set RightPicDesc='' , RightPicture='' where ID=" & CType(Trim(lblPageID.Text), Integer)
				.CommandType = CommandType.Text
				.Connection = Conn
				If Conn.State = ConnectionState.Closed Then
					Dim sConStr As String = ConfigurationSettings.AppSettings("sConnection")
					Try
						Conn.ConnectionString = sConStr
					Catch ex As Exception
					End Try
					Conn.Open()
				End If
				.ExecuteNonQuery()

				'referesh the page data
				Call GetContactData()
				Call GetData()

			End If
		End With

	End Sub

	Private Sub dlSubPages_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dlSubPages.SelectedIndexChanged

	End Sub
End Class
