Re: How do I pass variables to and from a custom dialog box?

  •  03-29-2006, 9:07 AM

    Re: How do I pass variables to and from a custom dialog box?

    Hi,
     
    Where should that code be? I get an object is null or undefined error with the following code:
     
    Calling page
     
    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
    <%@ Page Language="vb" ContentType="text/html" ResponseEncoding="iso-8859-1" debug="true"%>
    <script runat="server">
     Sub Page_Load
            Dim pos As Integer
            pos = Editor1.ToolControls.IndexOf("Italic") + 1
            Dim ctrl As System.Web.UI.WebControls.WebControl
            ctrl = Editor1.CreateCommandButton("MyButton", "text.gif", "Insert My Custom Text")
            ctrl.Attributes("onclick") = "ShowMyDialog(this)"
            Editor1.InsertToolControl(pos, "MyButton", ctrl)
        End Sub
    </script>
    <script language="JavaScript" type="text/javascript" >
     function ShowMyDialog(button)
     {
      //use CuteEditor_GetEditor(elementinsidetheEditor) to get the cute editor instance
      var editor=CuteEditor_GetEditor(button);
      //show the dialog page , and pass the editor as newwin.dialogArguments
      var newwin=showModelessDialog("selectInsert.htm?_rand="+new Date().getTime(),editor,"dialogWidth:400px;dialogHeight:300px");
     }
    </script>
    <html>
        <head>
      <link rel="stylesheet" href="../../example.css" type="text/css" />
     </head>
        <body >
            <form runat="server" ID="Form1">    
       <CE:Editor id="Editor1" runat="server" AutoConfigure="Minimal" FilesPath="CuteSoft_Client/CuteEditor/"></CE:Editor><br />   
      </form>
     </body>
    </html>
     
    Dialog box

    <html>
    <head>
    <title>Select insert</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <form name="frmInserts">
    <label>Select an insert type:</label><br/>
    <table width="200">
      <tr>
        <td>
          <input type="radio" name="radInserts" value="fig">
          Figure</td>
      </tr>
      <tr>
        <td>
          <input type="radio" name="radInserts" value="box">
          Box</td>
      </tr>
      <tr>
        <td>
          <input type="radio" name="radInserts" value="ref">
          Reference</td>
      </tr>
      <tr>
        <td>
          <input type="radio" name="radInserts" value="case">
          Case Study</td>
      </tr>
      <tr>
        <td>
          <input type="radio" name="radInserts" value="note">
          Note</td>
      </tr>
    </table>
    <br/>
    <label>Enter insert reference: </label>
    <input name="txtInsert" type="text">
    <br>
       <button onclick="button_click()">Insert</button>
       <button onclick="window.close()">Close</button>
    </form>
    </body>
    <script>
     function button_click()
     {
      for (i=0; i<frmInserts.radInserts.length; i++) {
       if (frmInserts.radInsertsIdea [I].checked) {
        var strClass = frmInserts.radInsertsIdea [I].value
       }
      }
      // get the cute editor instance
         var editor1 = document.getElementById('<%=Editor1.ClientID%>');
         //Get the editor selection
         var editselection=editor1.GetSelection();
      var strInsert = frmInserts.txtInsert.value;
      var strLink = "<a href='insert.htm?id="+strInsert+"' class='"+strClass+"'>"+editselection+"</a>"
      
      var editor=window.dialogArguments;
      
      editor.ExecCommand("pasteHTML",false,strLink);
     }
     </script>
    </html>
View Complete Thread