Insert JavaScript before PostBack Event

Insert JavaScript before PostBack Event

To call some javascript before the postback event is raised, use the following code:

if (!Page.ClientScript.IsOnSubmitStatementRegistered(type, “script_onsubmit_editor_” + ClientID))
{
   string popTextareaScript =
      “var ed = YAHOO.widget.EditorInfo.getEditorById(‘” + editor.ClientID + “‘);”
      + “ed.cleanHTML();”;
   Page.ClientScript.RegisterOnSubmitStatement(type,
      “script_onsubmit_editor_” + ClientID, popTextareaScript);
}

In the above code example I was trying to populate a textarea from the YUI Editor.

Leave a Reply

Your email address will not be published. Required fields are marked *