C# 为什么我的属性get_uu和set_uuu没有在AJAX控件中公开?
我试图创建一个AJAX控件,但无法看到控件中的属性get_uu和set_uu方法 这是我在.js文件中得到的代码:C# 为什么我的属性get_uu和set_uuu没有在AJAX控件中公开?,c#,asp.net,javascript,ajax,C#,Asp.net,Javascript,Ajax,我试图创建一个AJAX控件,但无法看到控件中的属性get_uu和set_uu方法 这是我在.js文件中得到的代码: Type.registerNamespace('MyCompany.ControlLibrary'); MyCompany.ControlLibrary.WebNotify = function(element) { // Module level variables this._message = ''; //Calling the base clas
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();
}
这是代码隐藏.cs文件中的我的属性:
[DescriptionAttribute("The message that is displayed in the notifier.")]
public string Message
{
get { return _message; }
set { _message = value; }
}
private string _message = "No Message Specified";
编辑:这是我的全部代码隐藏:
未命中[ExtenderControlProperty]属性的代码我不需要任何AJAX控制工具包的东西。我只需要使用$find而不是$get。现在我使用$find,一切都很完美
多么令人头痛。补充一点,这就是我试图调用客户端来检索/更新属性的代码:var notifier=$get'ntfTest';notifier.set_messagetext;我似乎没有那个。。。我是reference System.Web.Extensions,等等。它位于哪个名称空间?AjaxControlToolkit.ExtenderControlPropertyAttribute我已经添加了它,但它仍然没有出现在我的方法或属性列表中。还有一个-这些属性区分大小写,所以正确的JS:get\u Message,set\u Message已经尝试过了。还有其他想法吗?如果在JS调试器模式下查看对象,我甚至看不到我的get_uu和set_uu方法。我只能看到标准属性。
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
}
}