Highlights of problems in Ext. Net Development

Source: Internet
Author: User

1. The control cannot be obtained after the control is dynamically generated:

Protected void page_init (Object sender, eventargs e) {ComboBox cmbtest = new ComboBox (); cmbtest. id = "cmbtest"; initbooleandrop (cmbtest); cmbtest. directselect + = new componentdirectevent. directeventhandler (cmbtest_directselect); this. page. controls. add (cmbtest);} private void initbooleandrop (ComboBox CMB) {listitem item = new listitem (); item. TEXT = "--- Select ---"; item. value = "0"; CMB. items. add (item); item = new listitem (); item. TEXT = "Y"; item. value = "1"; CMB. items. add (item); item = new listitem (); item. TEXT = "N"; item. value = "2"; CMB. items. add (item); CMB. selecteditem. TEXT = CMB. items [0]. text;} // The selected value void cmbtest_directselect (Object sender, directeventargs e) {ComboBox CMB = (ComboBox) sender; X. MSG. alert (CMB. selecteditem. text, CMB. selecteditem. value ). show ();}

After testing for a long time, the problem lies in the following sentence:

 
This. Page. Controls. Add (cmbtest );

Just change it to the following sentence:

 
This. Form1.controls. Add (cmbtest );

2.CodeTo control the display and hide controls:
You cannot directly use the visible attribute for control. You should use the hide () and show () methods for control. For details, refer:

Http://forums.ext.net/showthread.php? 13114 & P = 54033 & viewfull = 1 # post54033

Http://forums.ext.net/showthread.php? 13114 & P = 54033 & viewfull = 1# Post54033visible and hidden are not the same. If visible= False then a widget is not rendered at all (it is absent on client side) therefore we cannot change visibility on client side.
You have to rerender the widget after set visible =True during directevent widget1.render ();If hidden= True then the widget is rendered but hidden in the browser, You Can easly to control visiblilty in the client side by hidden
Property during directevent

3. When creating a composite control, "the control with ID 'control id' not found" is displayed ":

The reason is that the control is not created in the "createchildcontrols" method;

4. gridpanel cannot obtain the selected row:

Cause: Set the idproperty of the model object in store to the field name.

5. When you use Ext. Net to create a custom control, the following error occurs:Token is not unique"Problem:

 "/" ApplicationProgramServer error. -------------------------------------------------------------------------------- Token is not unique ------------------- id = _ clientinittagname = anchormatch =  <  #: Anchor  ID  = "_ Clientinit"   />  Note: An unhandled exception occurs during the execution of the current Web request. Check the stack trace information for details about the error and the source of the error in the code. Exception details: transformer. net. tokennotuniqueexception: token is not unique ----------------- id = _ clientinittagname = anchormatch =  <  #: Anchor ID  = "_ Clientinit"   />  Source error: an unprocessed exception is generated during the execution of the current Web request. You can use the following exception stack trace information to determine the cause and location of the exception. Stack trace: [tokennotuniqueexception: token is not unique ----------------- id = _ clientinittagname = anchormatch =  <  #: Anchor  ID  = "_ Clientinit"   /> ] Transformer. net. token. parseanchors () + 508 transformer. net. texttransformer. parse (list '1 tokenstype, Dictionary '2 variables) + 1063 transformer. net. texttransformer. transform (list '1 tokenstype, Dictionary '2 variables) + 42 transformer. net. texttransformer. transform (list '1 tokenstype) + 41 transformer. net. texttransformer. transform () + 53 Ext. net. extnettransformer. transform (string text) + 210 Ext. net. initscriptfilter. transform () + 50 Ext. net. initscriptfilter. flush () + 74 system. web. httpwriter. filter (Boolean finalfiltering) + 8782518 system. web. httpresponse. filteroutput () + 82 system. web. callfilterexecutionstep. system. web. httpapplication. iexecutionstep. execute () + 47 system. web. httpapplication. executestep (iexecutionstep step, Boolean & completedsynchronously) + 75 

View code

This problem may occur because the created control is not added to the control library, as shown below:

Protected override void createchildcontrols ()
{
Viewport viewmain = New Viewport (); viewmain. ID = This . ID + " _ Viewmain " ; Viewmain. Layout = " Anchorlayout " ; Viewmain. autoscroll = True ; Viewmain. Border = False ; Viewmain. borderspec = " 0 0 0 0 " ; This . Controls. Add (viewmain); // if this statement is missing, the above error message is displayed.
}

The main reason is that the Control ID is repeated.

6. Ext. Net extends the custom control and saves the custom property status:

 Public   Class  Textfieldstate: Ext. net. Panel {  Private Textfield refertext;  Private  Ext. net. Panel referpanel;  Private   String  _ Text;  Private   String  _ Selecttext;  Public   Virtual   String  Text {  Get  {_ Text = Viewstate [ "  Text  "  ]. Tostring ();  Return  _ Text ;}  Set  {_ Text = Value; viewstate [  "  Text  " ] = _ Text;  If (Refertext! =Null  ) Refertext. Text = _ Text ;}} [Bindable (  True  )] [Localizable (  True  )]  Public   String  Selecttext {  Get  {_ Selecttext = Viewstate [ "  Selecttext "  ]. Tostring ();  Return  _ Selecttext ;}  Set  {_ Selecttext = Value; viewstate [  "  Selecttext  " ] = _ Selecttext ;}} 
<Ext: ResourceManagerID= "Resourcemanager1"Runat= "Server"Disableviewstate= "False" />// Update the property disableviewstate = "false" on the page"

When using the control, perform the following operations:

 Public   Partial   Class  Webform4: system. Web. UI. Page {  Protected  Textfieldstate txtfstate;  Protected  Void Page_init ( Object  Sender, eventargs e) {txtfstate = New  Textfieldstate (); txtfstate. ID = "  Txtfstate  "  ;  This  . Form1.controls. Add (txtfstate); Ext. net. Button BTN = New Ext. net. Button (); BTN. Text = "  Set  "  ; BTN. directevents. Click. viewstatemode = Viewstatemode. enabled; // Viewstate must be enabled BTN. directclick + = New  Ext. net. componentdirectevent. directeventhandler (btnset_directclick );  This  . Form1.controls. Add (BTN); BTN = New Ext. net. Button (); BTN. Text = "  Show  "  ;// Viewstate must be enabled
BTN. directevents. Click. viewstatemode = Viewstatemode. enabled; BTN. directclick + = New Ext. net. componentdirectevent. directeventhandler (btn_directclick); BTN. enableviewstate = True ; This . Form1.controls. Add (BTN );} Void Btnset_directclick ( Object Sender, ext. net. directeventargs e) {txtfstate. Text = " Ddddfdfd " ; Txtfstate. selecttext = " Aaaaaa " ;} Void Btn_directclick (Object Sender, ext. net. directeventargs e) {X. msg. Alert ( " Prompt " , Txtfstate. Text + " | " + Txtfstate. selecttext). Show ();}}

The execution is as follows:

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.