Numeric or Currency formatting

Last post 01-18-2011, 11:24 AM by srp10. 5 replies.
Sort Posts: Previous Next
  •  01-10-2011, 9:36 PM 65664

    Numeric or Currency formatting

    I would like to provide my end user to to format the numeric values or to currency.
     
    For example i would like to format
    12345.5678 =>   12345.45 or    $12345.45 or similar standard numeric formats as in word or subset of them.
     
    Can you let me know how to do this ?
     
    Thanks,
     
  •  01-11-2011, 2:18 AM 65666 in reply to 65664

    Re: Numeric or Currency formatting

    Hi srp10,
     
    Please try ues HTMLFilter, more info refer to http://www.cutesoft.net/developer+guide/scr/Creates-your-own-HTML-Filter.htm
     
    Regards,
     
    Ken
  •  01-14-2011, 2:57 PM 65728 in reply to 65666

    Re: Numeric or Currency formatting

    Thanks for your reply.
     
    Can you please provide me more description. 
     
    My body of the editor contains multiple numbers  and text. I want to provide end user  button(s) in the tool bar.
    The end user will highlight the each number in the body and format it to 2,3 or 4 digit  number or currency field by pressing appropriate toolbar button.
     
    The is  should be same as highlighting some text on the editor and change the color or bold or underline.
     
    Can you please help me with this.
  •  01-17-2011, 6:49 PM 65747 in reply to 65728

    Re: Numeric or Currency formatting

    Please help me in this
  •  01-17-2011, 7:36 PM 65749 in reply to 65747

    Re: Numeric or Currency formatting

    Hi srp10,
     
    Please test the example below, it shows you how to add a custom button into toolbar of editor and change the selected text to you own format by this button.
     
    1. <%@ Page Language="C#" %>  
    2.   
    3. <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>  
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    5.   
    6. <script runat="server">  
    7.     protected override void OnLoad(EventArgs e)  
    8.     {  
    9.         //add custom button into the toolbar  
    10.         CuteEditor.ToolControl tc = Editor1.ToolControls["insertcustombutonhere"];  
    11.         if (tc != null)   
    12.         {   
    13.             System.Web.UI.WebControls.Image Image1 = new System.Web.UI.WebControls.Image();   
    14.             Image1.ToolTip = "Insert today's date";  
    15.             Image1.ImageUrl = "tools.gif";  
    16.             Image1.CssClass = "CuteEditorButton";  
    17.             Image1.Attributes["onclick"] = "changeText()";  
    18.             tc.Control.Controls.Add(Image1);  
    19.         }  
    20.         base.OnLoad(e);  
    21.     }  
    22. </script>  
    23.   
    24. <html xmlns="http://www.w3.org/1999/xhtml">  
    25. <head runat="server">  
    26.     <title>Untitled Page</title>  
    27. </head>  
    28. <body>  
    29.     <form id="form1" runat="server">  
    30.         <div>  
    31.             <CE:Editor ID="Editor1" runat="server" >  
    32.             </CE:Editor>  
    33.         </div>  
    34.     </form>  
    35. </body>  
    36. </html>  
    37. <script>  
    38. //get the selected text of editor  
    39. function getSelectedHTML(){  
    40.       var editor1=document.getElementById("<%= Editor1.ClientID %>");  
    41.       // get the active editor window  
    42.       var editwin = editor1.GetWindow();  
    43.   
    44.   
    45.       // get the active editor document  
    46.       var editdoc = editor1.GetDocument();  
    47.   
    48.       var rng=null,html="";   
    49.       if (document.selection && document.selection.createRange){  
    50.         rng=editdoc.selection.createRange();  
    51.         html=rng.htmlText||"";  
    52.       }else if (window.getSelection){  
    53.         rng=editwin.getSelection();  
    54.   
    55.         if (rng.rangeCount > 0 && window.XMLSerializer){  
    56.           rng=rng.getRangeAt(0);  
    57.           html=new XMLSerializer().serializeToString(rng.cloneContents());  
    58.         }  
    59.       }  
    60.       return html;  
    61.  }  
    62.  //change the selected text to the format you need  
    63.  function changeText()  
    64.  {  
    65.     var editor1=document.getElementById("<%= Editor1.ClientID %>");  
    66.     editor1.PasteHTML("$"+getSelectedHTML());  
    67.  }  
    68.   
    69. </script> 
     
    Regards,
     
    Ken
  •  01-18-2011, 11:24 AM 65771 in reply to 65749

    Re: Numeric or Currency formatting

    It worked.
    Thank  you.
View as RSS news feed in XML