2009-08-17 5 views
0

AJAXコントロールを作成しようとしていますが、コントロール内のget_メソッドとset_メソッドのプロパティが表示されません。なぜ私のプロパティはget_とset_がAJAXコントロールに公開されていませんか?

これは私が私の.jsでファイル持っているコードです:これは.csファイル、ファイルの背後にあるコードでは私の財産です

Type.registerNamespace('MyCompany.ControlLibrary'); 

MyCompany.ControlLibrary.WebNotify = function(element) 
{ 
    // Module level variables 
    this._message = ''; 

    //Calling the base class constructor 
    MyCompany.ControlLibrary.WebNotify.initializeBase(this, [element]); 
} 


MyCompany.ControlLibrary.WebNotify.prototype = 
{ 
    //Getter for Message Property 
    get_message : function() 
    { 
     return this._message; 
    }, 

    //Setter for Message Property 
    set_message : function(value) 
    {debugger; 
     var e = Function._validateParams(arguments, [{name: 'value', type: String}]); 
     if (e) throw e; 

     if (this._message != value) 
     { 
      // Only sets the value if it differs from the current 
      this._message = value; 
      //Raise the propertyChanged event 
      this.raisePropertyChanged('message'); //This is a base class method which resides in Sys.Component 
     } 
    }, 

    initialize : function() 
    { 
     //Call the base class method 
     MyCompany.ControlLibrary.WebNotify.callBaseMethod(this, 'initialize'); 
    }, 

    dispose : function() 
    { 
     //Call the base class method 
     MyCompany.ControlLibrary.WebNotify.callBaseMethod(this, 'dispose'); 
    } 
} 





MyCompany.ControlLibrary.WebNotify.registerClass('MyCompany.ControlLibrary.WebNotify', Sys.UI.Control); 

if (typeof(Sys) != 'undefined') 
{ 
    Sys.Application.notifyScriptLoaded(); 
} 

を:

[DescriptionAttribute("The message that is displayed in the notifier.")] 
public string Message 
{ 
    get { return _message; } 
    set { _message = value; } 
} 
private string _message = "No Message Specified"; 

EDIT:これは私の全体ですコードの背後にあるコード:

using System; 
using System.Data; 
using System.Configuration; 
using System.Web; 
using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.Web.UI.HtmlControls; 
using System.ComponentModel; 
using System.Web.Services; 
using System.Collections.Generic; 

namespace MyCompany 
{ 
    [DefaultProperty("ID")] 
    [ToolboxData("<{0}:WebNotify runat=server />")] 
    public class WebNotify : Button, IScriptControl 
    { 


#region Constructors 

     public WebNotify() 
     { 

     } 

#endregion 


#region Page Events 


     protected override void OnLoad(EventArgs e) 
     { 
      base.OnLoad(e); 
     } 

     protected override void OnInit(EventArgs e) 
     { 
      base.OnInit(e); 
     } 

     protected override void OnPreRender(EventArgs e) 
     { 

      if (!this.DesignMode) 
      { 
       ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page); 
       if (scriptManager != null) 
       { 
        scriptManager.RegisterScriptControl(this); 
       } 
       else 
        throw new ApplicationException("You must have a ScriptManager on the Page."); 
      } 

      base.OnPreRender(e); 

     } 

     protected override void Render(HtmlTextWriter writer) 
     { 
      if (!this.DesignMode) 
      { 
       ScriptManager.GetCurrent(this.Page).RegisterScriptDescriptors(this); 
      } 
      base.Render(writer); 
     } 

     protected override void CreateChildControls() 
     { 

      base.CreateChildControls(); 

     } 



#endregion 


#region Properties 


     [DescriptionAttribute("The message that is displayed in the notifier.")] 
     public string Message 
     { 
      get { return _message; } 
      set { _message = value; } 
     } 
     private string _message = "No Message Specified"; 



#endregion 



#region IScriptControl 


     IEnumerable<ScriptDescriptor> IScriptControl.GetScriptDescriptors() 
     { 
      ScriptControlDescriptor desc = new ScriptControlDescriptor("MyCompany.WebNotify", ClientID); 
      desc.AddProperty("message", this.Message); 
      yield return desc; 
     } 

     IEnumerable<ScriptReference> IScriptControl.GetScriptReferences() 
     { 
      yield return new ScriptReference(Page.ResolveUrl("~/WebNotify.js")); 
     } 


#endregion 


    } 
} 
+0

ちょうどこれを追加するには、これはクライアントサイドでプロパティを取得/更新するために呼び出すコードです。 var notifier = $ get( 'ntfTest'); notifier.set_message(text); – GenericTypeTea

答えて

0

私はAJAXコントロールキットのものは必要ありませんでした。 $ getの代わりに$ findを使用しなければなりませんでした。今私はすべてのものが完璧に動作することを見つけるために$を使用している

どのような頭痛。

0

コードミス[ExtenderControlProperty]属性

+0

私はそれを持っていないようです...私は参照System.Web.Extensions、などですそれはどの名前空間にありますか? – GenericTypeTea

+0

AjaxControlToolkit.ExtenderControlPropertyAttribute – Dewfy

+0

これを追加しましたが、それでもメソッドまたはプロパティリストには表示されません。 – GenericTypeTea

関連する問題