I am creating a AJAX Extender Control and would like to pass a value back to the server on post-back. Are ExtenderControlProperties two-way? If not, is there any way of making them two way?
A:
Apparently the ExtenderControlProperties are not two-way. I solved this using a hiddenfield. This is how I implemented it.
I put this In the extender
protected override void OnInit(EventArgs e)
{
HiddenFieldId = ClientID + "_HiddenValue";
Page.ClientScript.RegisterHiddenField(HiddenFieldId, "");
base.OnInit(e);
}
[ExtenderControlProperty]
[DefaultValue("")]
public string HiddenFieldId
{
get { return GetPropertyValue("HiddenFieldId", ""); }
set { SetPropertyValue("HiddenFieldId", value); }
}
public string HiddenFieldValue
{
get { return Page.Request.Form[HiddenFieldId]; }
}
and this in the behaviour
//In the prototype
get_HiddenFieldId: function() {
return this._hiddenFieldId;
},
set_HiddenFieldId: function(value) {
this._hiddenFieldId = value;
},
//In the initialisation
this._hiddenFieldId = null;
//In my method when I want to set the hidden value.
document.getElementById(this._hiddenFieldId).value = valueToSet;
helios456
2009-11-18 14:11:16