Re: How do you get the editor in an existing textarea

  •  03-23-2005, 5:37 PM

    Re: How do you get the editor in an existing textarea

    I have changed the control name to Editor1, and here is the code behind:
     
    'Using Statements @1-E5FBC350
    Imports System
    Imports System.Collections
    Imports System.Collections.Specialized
    Imports System.ComponentModel
    Imports System.Data
    Imports System.Drawing
    Imports System.Web
    Imports System.Web.SessionState
    Imports System.Web.UI
    Imports System.Web.UI.WebControls
    Imports System.Web.UI.HtmlControls
    Imports System.Text.RegularExpressions
    Imports System.Globalization
    Imports NewProject1
    Imports NewProject1.Data
    Imports NewProject1.Security
    Imports NewProject1.Configuration
    Imports NewProject1.Controls
    Namespace Yes [Y]
    'End Using Statements
    'Forms Definition @1-A03C6C47
    Public Class [yPage]
    Inherits System.Web.UI.Page
    'End Forms Definition
    'Forms Objects @1-EBD5F1A0
        Protected editor1Data As editor1DataProvider
        Protected editor1Error As System.Web.UI.WebControls.PlaceHolder
        Protected editor1Holder As System.Web.UI.HtmlControls.HtmlControl
        Protected editor1ErrorLabel As System.Web.UI.WebControls.Label
        Protected editor1Errors As NameValueCollection = New NameValueCollection()
        Protected editor1Operations As FormSupportedOperations
        Protected editor1Name As System.Web.UI.WebControls.TextBox
        Protected editor1Editor1 As System.Web.UI.WebControls.TextBox
        Dim Protected editor1Button_Insert As HtmlInputButton
        Dim Protected editor1Button_Update As HtmlInputButton
        Dim Protected editor1Button_Delete As HtmlInputButton
    'End Forms Objects
    'Page_Load Event @1-A2D2CF1E
    Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
    'End Page_Load Event
    'Page_Load Event BeforeIsPostBack @1-49DCD044
        If Not IsPostBack Then
                Dim PageData As PageDataProvider = New PageDataProvider()
                Dim item As PageItem = PageItem.CreateFromHttpRequest()
                PageData.FillItem(item)
                editor1Show()
        End If
    'End Page_Load Event BeforeIsPostBack
    'Page_Load Event tail @1-E31F8E2A
    End Sub
    'End Page_Load Event tail
    'Page_Unload Event @1-D998A98F
    Protected Overrides Sub OnUnload(ByVal e As System.EventArgs)
    'End Page_Unload Event
    'Page_Unload Event tail @1-E31F8E2A
    End Sub
    'End Page_Unload Event tail
    'Record Form editor1 Parameters @2-FC249DD2
        Protected Sub editor1Parameters()
            Try
                editor1Data.UrlDesignetID = IntegerParameter.GetParam(Request.QueryString("DesignetID"))
            Catch e As Exception
                editor1Errors.Add("Parameters","Form Parameters: " + e.Message)
            End Try
        End Sub
    'End Record Form editor1 Parameters
    'Record Form editor1 Show method @2-E40B16BD
        Protected Sub editor1Show()
            If editor1Operations.None Then
                editor1Holder.Visible = False
                Return
            End If
            Dim item As editor1Item = editor1Item.CreateFromHttpRequest()
            Dim IsInsertMode As Boolean = Not editor1Operations.AllowRead
            editor1Errors.Add(item.errors)
            If editor1Errors.Count > 0 Then
                editor1ShowErrors()
                Return
            End If
    'End Record Form editor1 Show method
    'Record Form editor1 BeforeShow tail @2-AA7B3AEB
            editor1Parameters()
            editor1Data.FillItem(item, IsInsertMode)
            editor1Button_Insert.Visible=IsInsertMode AndAlso editor1Operations.AllowInsert
            editor1Button_Update.Visible=Not(IsInsertMode) AndAlso editor1Operations.AllowUpdate
            editor1Button_Delete.Visible=Not(IsInsertMode) AndAlso editor1Operations.AllowDelete
            editor1Name.Text=item.Name.GetFormattedValue()
            editor1Editor1.Text=item.Editor1.GetFormattedValue()
    'End Record Form editor1 BeforeShow tail
    'Record Form editor1 Show method tail @2-887627E0
            If editor1Errors.Count > 0 Then
                editor1ShowErrors()
            End If
        End Sub
    'End Record Form editor1 Show method tail
    'Record Form editor1 LoadItemFromRequest method @2-4E87066F
        Protected Sub editor1LoadItemFromRequest(item As editor1Item, ByVal EnableValidation As Boolean)
            item.Name.SetValue(editor1Name.Text)
            item.Editor1.SetValue(editor1Editor1.Text)
            If EnableValidation Then
                item.Validate(editor1Data)
            End If
            editor1Errors.Add(item.errors)
        End Sub
    'End Record Form editor1 LoadItemFromRequest method
    'Record Form editor1 GetRedirectUrl method @2-91CCBCDA
        Protected Function Geteditor1RedirectUrl(ByVal redirect As String, ByVal removeList As String) As String
            Dim parameters As New LinkParameterCollection()
            If redirect = "" Then redirect = "y.aspx"
            Return redirect + "?" + parameters.ToString("GET",removeList,ViewState)
        End Function
    'End Record Form editor1 GetRedirectUrl method
    'Record Form editor1 ShowErrors method @2-F6F912B6
        Protected Sub editor1ShowErrors()
            Dim DefaultMessage As String = ""
            Dim i As Integer
            For i = 0 To editor1Errors.Count - 1
            Select Case editor1Errors.AllKeys(i)
                Case Else
                    DefaultMessage = DefaultMessage & editor1Errors(i) & "<br>"
            End Select
            Next i
            editor1Error.Visible = True
            editor1ErrorLabel.Text = DefaultMessage
        End Sub
    'End Record Form editor1 ShowErrors method
    'Record Form editor1 Insert Operation @2-198BBB74
        Protected Sub editor1_Insert(ByVal sender As Object, ByVal e As System.EventArgs)
            Dim item As editor1Item = New editor1Item()
            Dim ExecuteFlag As Boolean = True
            Dim ErrorFlag As Boolean = False
            Dim RedirectUrl As String = ""
            Dim EnableValidation As Boolean = False
    'End Record Form editor1 Insert Operation
    'Button Button_Insert OnClick. @3-B08F0301
            If CType(sender,Control).ID = "editor1Button_Insert" Then
                RedirectUrl = Geteditor1RedirectUrl("", "")
                EnableValidation  = True
    'End Button Button_Insert OnClick.
    'Button Button_Insert OnClick tail. @3-477CF3C9
            End If
    'End Button Button_Insert OnClick tail.
    'Record Form editor1 BeforeInsert tail @2-1E69A02A
        editor1Parameters()
        editor1LoadItemFromRequest(item, EnableValidation)
        If editor1Operations.AllowInsert Then
            ErrorFlag=(editor1Errors.Count > 0)
            If ExecuteFlag And (Not ErrorFlag) Then
                Try
                    editor1Data.InsertItem(item)
                Catch ex As Exception
                    editor1Errors.Add("DataProvider",ex.Message)
                    ErrorFlag = True
                End Try
            End If
    'End Record Form editor1 BeforeInsert tail
    'Record Form editor1 AfterInsert tail  @2-7269FD99
            End If
            If ErrorFlag Then
                editor1ShowErrors()
            Else
                Response.Redirect(RedirectUrl)
            End If
        End Sub
    'End Record Form editor1 AfterInsert tail
    'Record Form editor1 Update Operation @2-CD608DE1
        Protected Sub editor1_Update(ByVal sender As Object, ByVal e As System.EventArgs)
            Dim item As editor1Item = New editor1Item()
            item.IsNew = False
            Dim ExecuteFlag As Boolean = True
            Dim ErrorFlag As Boolean = False
            Dim RedirectUrl As String = ""
            Dim EnableValidation As Boolean = False
    'End Record Form editor1 Update Operation
    'Button Button_Update OnClick. @4-7DB23FCA
            If CType(sender,Control).ID = "editor1Button_Update" Then
                RedirectUrl = Geteditor1RedirectUrl("", "")
                EnableValidation  = True
    'End Button Button_Update OnClick.
    'Button Button_Update OnClick tail. @4-477CF3C9
            End If
    'End Button Button_Update OnClick tail.
    'Record Form editor1 Before Update tail @2-3D5C7F61
            editor1Parameters()
            editor1LoadItemFromRequest(item, EnableValidation)
            If editor1Operations.AllowUpdate Then
            ErrorFlag = (editor1Errors.Count > 0)
            If ExecuteFlag And (Not ErrorFlag) Then
                Try
                    editor1Data.UpdateItem(item)
                Catch ex As Exception
                    editor1Errors.Add("DataProvider",ex.Message)
                    ErrorFlag = True
                End Try
            End If
    'End Record Form editor1 Before Update tail
    'Record Form editor1 Update Operation tail @2-7269FD99
            End If
            If ErrorFlag Then
                editor1ShowErrors()
            Else
                Response.Redirect(RedirectUrl)
            End If
        End Sub
    'End Record Form editor1 Update Operation tail
    'Record Form editor1 Delete Operation @2-A7DD2D20
        Protected Sub editor1_Delete(ByVal sender As Object, ByVal e As System.EventArgs)
            Dim ExecuteFlag As Boolean = True
            Dim ErrorFlag As Boolean = False
            Dim RedirectUrl As String = ""
            Dim EnableValidation As Boolean = False
            Dim item As editor1Item = New editor1Item()
            item.IsNew  = False
            item.IsDeleted  = True
    'End Record Form editor1 Delete Operation
    'Button Button_Delete OnClick. @5-0A395CF6
            If CType(sender,Control).ID = "editor1Button_Delete" Then
                RedirectUrl = Geteditor1RedirectUrl("", "")
                EnableValidation  = False
    'End Button Button_Delete OnClick.
    'Button Button_Delete OnClick tail. @5-477CF3C9
            End If
    'End Button Button_Delete OnClick tail.
    'Record Form BeforeDelete tail @2-2D3C6FAC
            editor1Parameters()
            editor1LoadItemFromRequest(item, EnableValidation)
            If editor1Operations.AllowDelete Then
            ErrorFlag = (editor1Errors.Count > 0)
            If ExecuteFlag And (Not ErrorFlag) Then
                Try
                    editor1Data.DeleteItem(item)
                Catch ex As Exception
                    editor1Errors.Add("DataProvider",ex.Message)
                    ErrorFlag = True
                End Try
            End If
    'End Record Form BeforeDelete tail
    'Record Form AfterDelete tail @2-7269FD99
            End If
            If ErrorFlag Then
                editor1ShowErrors()
            Else
                Response.Redirect(RedirectUrl)
            End If
        End Sub
    'End Record Form AfterDelete tail
    'Record Form editor1 Cancel Operation @2-B630D1BA
        Protected Sub editor1_Cancel(ByVal sender As Object, ByVal e As System.EventArgs)
            Dim item As editor1Item = New editor1Item()
            Dim RedirectUrl As String = ""
            editor1LoadItemFromRequest(item, True)
    'End Record Form editor1 Cancel Operation
    'Record Form editor1 Cancel Operation tail @2-EA2B0FFB
            Response.Redirect(RedirectUrl)
        End Sub
    'End Record Form editor1 Cancel Operation tail
    'OnInit Event @1-3349F5FF
        #Region " Web Form Designer Generated Code "
        Protected Overrides Sub OnInit(ByVal e As EventArgs)
            '
            ' CODEGEN: This call is required by the ASP.NET Web Form Designer.
            '
            InitializeComponent()
            'Me.Load += new System.EventHandler(this.Page_Load);
            'Me.Unload += new System.EventHandler(this.Page_Unload);
            MyBase.OnInit(e)
            editor1Data = New editor1DataProvider()
            editor1Operations = New FormSupportedOperations(False, True, True, True, True)
    'End OnInit Event
    'OnInit Event tail @1-E31F8E2A
        End Sub
    'End OnInit Event tail
    'InitializeComponent Event @1-EA5E2628
        ' <summary>
        ' Required method for Designer support - do not modify
        ' the contents of this method with the code editor.
        ' </summary>
        Private Sub InitializeComponent()
        End Sub
        #End Region
    'End InitializeComponent Event
    'Page class tail @1-DD082417
    End Class
    End Namespace
    'End Page class tail
View Complete Thread