Hi All,
For some reason I can't get the following to work: I have a custom AJAX Control Extender with a few getters and setters. I also have some images I want to use with the extender saved in a resource file. How to I make the respective image URLs available to the javascript of the extender? Are there any examples available?
Thanks!
[Update: renamed the subject to something more appropriate.]
![]() |
0 |
![]() |
Perhaps I can clarify a bit:
I have set up a getter and setter to set the image URL from the resource file:
1 [ExtenderControlProperty] 2 public string CoverURL 3 { 4 get { return GetPropertyValue("CoverURL", ""); } 5 set { SetPropertyValue("CoverURL", value); } 6 } 7 8 protected override void OnInit(EventArgs e) 9 { 10 this.CoverURL = Page.ClientScript.GetWebResourceUrl(this.GetType(), "AjaxControlExtender1.Resources.spacer.png"); 11 base.OnInit(e); 12 }And the following in the JS file:
1 get_CoverURL : function () { return this._CoverURL; }, 2 set_CoverURL : function (value) { this._CoverURL = value; },Is there a way to populate this._CoverURL on the client-side without using extender properties? I don't want to expose this as a property to the developer using my Control Extender.
Thanks!
![]() |
0 |
![]() |
Hi,
Thank you for your post!
I think you can do this in GetScriptDescriptors method:
protected override IEnumerableGetScriptDescriptors(Control targetControl)
{
ScriptBehaviorDescriptor descriptor = new ScriptBehaviorDescriptor("Samples.FocusBehavior", targetControl.ClientID);
descriptor.AddProperty("CoverURL ", Page.ClientScript.GetWebResourceUrl(this.GetType(), "AjaxControlExtender1.Resources.spacer.png"));
return new ScriptDescriptor[] { descriptor };
}For more information, see http://msdn2.microsoft.com/zh-cn/library/bb386403.aspx.
If you have further questionss,let meknow!
Best Regards,
Sincerely,
Jin-Yu Yin
Microsoft Online Community Support
![]() |
0 |
![]() |