Humble accounting voucher amount input control (re-enhanced) [GO]

Source: Internet
Author: User

usingSystem;usingSystem.ComponentModel;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;namespacevoucher{[Defaultproperty ("Jtext")] [ToolBoxData (@"<{0}:voucherinput jtext = ' runat= ' server ></{0}:VoucherInput>")    ]    //Set the default properties     Public classVoucherinput:webcontrol {PrivateTextBox _textbox;//integer digits        PrivateTextBox _ptextbox;//Decimal digits        #regionProperty[Bindable (true), Category ("appearance"), DefaultValue (""), Description ("Amount")        ]         Public stringJtext {Get{ensurechildcontrols (); return_textbox.text +"."+_ptextbox.text; }            Set{ensurechildcontrols (); if(Value = =""|| Value = =NULL)                {                                   }                Else                {                    string[] allstring = value. Split ('.'); _textbox.text= allstring[0]; _ptextbox.text= allstring[1]; }            }        }        #endregionProperties Delegated to child controls#regionMethodprotected Override voidCreateChildControls () {controls.clear (); _textbox=NewTextBox (); _textbox.id="TextBox1"; _textbox.maxlength= -; _textbox.width= -; _textbox.height= -; _textbox.attributes.add ("onkeypress","keyPress ()"); _textbox.style.add (Htmltextwriterstyle.backgroundimage,"URL (text.gif)"); _textbox.style.add (Htmltextwriterstyle.direction,"RTL"); _textbox.style.add (Htmltextwriterstyle.borderwidth,"0"); _ptextbox=NewTextBox (); _ptextbox.width= the; _ptextbox.height= -; _ptextbox.maxlength=2; _ptextbox.id="Ptextbox"; _ptextbox.style.add (Htmltextwriterstyle.backgroundimage,"URL (textpoint.gif)"); _ptextbox.style.add (Htmltextwriterstyle.borderwidth,"0"); _ptextbox.attributes.add ("onfocus","Pfocus ()"); _ptextbox.attributes.add ("onkeypress","pkeypress ()");  This.            Controls.Add (_textbox);  This.        Controls.Add (_ptextbox); }        protected Override voidRender (HtmlTextWriter writer) {AddAttributesToRender (writer);            _textbox.rendercontrol (writer);            _ptextbox.rendercontrol (writer); Writer. Write ("<script language=javascript>function keyPress () {if (!) ( event.keycode>=48&&event.keycode<=57 | | event.keycode==46 | | event.keycode==45)) {event.keycode = 0;} if (event.keycode==46) {Event.keycode = 0;document.getelementbyid (' Ptextbox '). focus ();}} </script>");//control of the characterWriter. Write ("<script language=javascript>function Pfocus () {var Box=document.getelementbyid (' Ptextbox '); var rng = Box.createtextrange (); Rng.collapse (TRUE); Rng.moveend (' character ', 2); Rng.movestart (' character ', 0); Rng.select (); }</script>"); Writer. Write ("<script language=javascript>function pkeypress () {if (event.keycode==46) {event.keycode = 0;} if (!) ( event.keycode>=48&&event.keycode<=57 | | event.keycode==46 | | event.keycode==45)) {event.keycode = 0;}} </script>"); }        #endregionOverriden methods    }}

Humble accounting voucher amount input control (re-enhanced) [GO]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.