Search code examples
asp.netvalidationwysiwyg

required field validation for wysiwyg editor


i am using third party wysiwyg editor in asp.net web form and its register with

<%@ Register TagPrefix="editor" Assembly="WYSIWYGEditor" Namespace="InnovaStudio" %>

here is the code for that returns

<editor:WYSIWYGEditor runat="server" ID="txtDesc" />

in cs file this are the settings for wysiwyg

        //'***************************************************
    //'   SETTING EDITOR DIMENSION (WIDTH x HEIGHT)
    //'***************************************************

    //'***************************************************
    //'   SETTING EDITING MODE
    //'   
    //'   Possible values: 
    //'       - "HTMLBody" (default) 
    //'       - "XHTMLBody" 
    //'       - "HTML" 
    //'       - "XHTML"
    //'***************************************************

    txtDesc.EditMode = "XHTMLBody";



    //'***************************************************
    //'   SETTING EDITOR DIMENSION (WIDTH x HEIGHT)
    //'***************************************************

    txtDesc.EditorWidth = 750.ToString(); //'You can also use %, for example: oEditSummary.EditorWidth = "100%"
    txtDesc.EditorHeight = 450.ToString();

    //'***************************************************
    //'   SHOWING DISABLED BUTTONS
    //'***************************************************

    txtDesc.btnPrint = true;
    txtDesc.btnPasteText = true;
    txtDesc.btnFlash = true;
    txtDesc.btnMedia = true;
    txtDesc.btnLTR = true;
    txtDesc.btnRTL = true;
    txtDesc.btnSpellCheck = true;
    txtDesc.btnStrikethrough = true;
    txtDesc.btnSuperscript = true;
    txtDesc.btnSubscript = true;
    txtDesc.btnClearAll = true;
    txtDesc.btnStyles = true; //'Show "Styles/Style Selection" button

    //'***************************************************
    //'   SPECIFY onSave EVENT COMMAND
    //'***************************************************

    //oEditSummary.onSave="document.forms.Form1.elements.btnSubmit.click();"

    //'***************************************************
    //'   APPLYING STYLESHEET 
    //'   (Using external css file)
    //'***************************************************

    txtDesc.Css = "style/test.css"; //'Specify external css file here

    //'***************************************************
    //'   APPLYING STYLESHEET 
    //'   (Using predefined style rules)
    //'***************************************************

    //'oEditSummary.StyleList = New String(,){ _
    //'       {"BODY",false,"","font-family:Verdana,Arial,Helvetica;font-size:x-small;"}, _
    //'       {".ScreenText",true,"Screen Text","font-family:Tahoma;"}, _
    //'       {".ImportantWords",true,"Important Words","font-weight:bold;"}, _
    //'       {".Highlight",true,"Highlight","font-family:Arial;color:red;"}}

    //'If you'd like to set the default writing to "Right to Left", use:

    //'oEditSummary.StyleList = New String(,){{"BODY",false,"","direction:rtl;unicode-bidi:bidi-override;"}}


    //'***************************************************
    //'   ENABLE ASSET MANAGER ADD-ON
    //'***************************************************

    txtDesc.AssetManagerWidth = 570.ToString();
    txtDesc.AssetManagerHeight = 510.ToString();
    txtDesc.AssetManager = System.Configuration.ConfigurationManager.AppSettings["EditorPath"].ToString() + "/Editor/assetmanager/assetmanager.aspx";
    txtDesc.scriptPath = System.Configuration.ConfigurationManager.AppSettings["EditorPath"].ToString() + "/Editor/scripts/";
    //'Use relative to root path (starts with "/")

    //'***************************************************
    //'   USING CUSTOM TAG INSERTION FEATURE
    //'***************************************************

    txtDesc.CustomTagList = new String[,]{{"First Name","{%first_name%}"},
                                            {"Last Name","{%last_name%}"},
                                            {"Email","{%email%}"}};

    //'***************************************************
    //'   SETTING COLOR PICKER's CUSTOM COLOR SELECTION
    //'***************************************************
    txtDesc.CustomColors = new String[] { "#ff4500", "#ffa500", "#808000", "#4682b4", "#1e90ff", "#9400d3", "#ff1493", "#a9a9a9" };

    //'***************************************************
    //'   SETTING EDITING MODE
    //'   
    //'   Possible values: 
    //'       - "HTMLBody" (default) 
    //'       - "XHTMLBody" 
    //'       - "HTML" 
    //'       - "XHTML"
    //'***************************************************

    txtDesc.EditMode = "XHTMLBody";

and i want to give required field validation. so how its possible?


Solution

  • I've done some reading around this and it seems your best solution is to implement a Custom Validator for your control, you can provide Client and Server side implementation no problem - heres a quick guide on how to do that:

    http://www.codeproject.com/Articles/3882/ASP-NET-Validators-Unclouded

    See the section on Custom Validators.