2011-11-18 2 views
1

내선 마크 업는 콤보 상자에서 선택 핸들러와 DirectMethod 전화 Ext.net

<Listeners> 
    <Select Handler="Ext.net.DirectMethods.loadcombo2();" /> 
    </Listeners> 

C#

[DirectMethod] 
protected void loadcombo2() 
{ 
    this.ComboBox2.AddItem("List1", "L1"); 
    this.ComboBox2.AddItem("List2", "L2"); 

} 

어떻게 콤보 세포 변화에 직접 메소드를 호출하는?

메신저이

Uncaught TypeError: Object #<Object> has no method 'loadcombo2' 

답변

1

시도에 대한 오류가 발생하는 것은 당신이 코드를 시도 할 수 있습니다 공개 설정 대신 loadcombo2

에 대한 보호하기 위해, 그것은 나를 위해 잘 작동 :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<script runat="server"> 
    protected void Page_Load(object sender, EventArgs e) 
    { 
     if (!X.IsAjaxRequest) { 
      this.Store1.DataSource = new object[] { 
       new object[] {"AL", "Alabama", "The Heart of Dixie"}, 

      }; 

      this.Store1.DataBind(); 
     } 

    } 

    [DirectMethod] 
    public void LoadCombo2() { 
     this.ComboBox1.AddItem("List1", "L1"); 
     this.ComboBox1.AddItem("List2", "L2"); 
    } 

</script> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head id="Head1" runat="server"> 
    <title>Comboboxes - Ext.NET Examples</title> 
</head> 
<body> 
    <form id="Form1" runat="server"> 
     <ext:ResourceManager ID="ResourceManager1" runat="server" /> 

     <ext:Store ID="Store1" runat="server"> 
      <Reader> 
       <ext:ArrayReader> 
        <Fields> 
         <ext:RecordField Name="abbr" /> 
         <ext:RecordField Name="state" /> 
         <ext:RecordField Name="nick" /> 
        </Fields> 
       </ext:ArrayReader> 
      </Reader>    
     </ext:Store> 

     <h2>Not Editable:</h2> 

     <ext:ComboBox 
      ID="ComboBox1" 
      runat="server" 
      StoreID="Store1" 
      Editable="false" 
      DisplayField="state" 
      ValueField="abbr" 
      TypeAhead="true" 
      Mode="Local" 
      ForceSelection="true" 
      EmptyText="Select a state..." 
      Resizable="true" 
      SelectOnFocus="true" 
      > 
      <Listeners> 
       <Select Handler="DT.Everest.DocFlow.LoadCombo2();" /> 
      </Listeners> 

      </ext:ComboBox> 
    </form> 
</body> 
</html> 
2

I을 여기서는 Select Direct 이벤트를 사용하는 것이 가장 좋습니다.

으로 기존 직접적인 방법을 바꾸기 :

protected void LoadCombo2(object sender, DirectEventArgs e) { 
    this.ComboBox1.AddItem("List1", "L1"); 
    this.ComboBox1.AddItem("List2", "L2"); 
} 

그리고 리스너를 대체 :

<DirectEvents> 
    <Select OnEvent="LoadCombo2" /> 
</DirectEvents> 
관련 문제