Hi.
I have a custom control that inherits from TextBox and implements ICallbackEventHandler.
The control is kind of an extended ajax autocomplete/suggestions one.
Aside from the Text property of the Textbox I have extended the control with a Value property.
The idea is that a Hiddenfield control is assigned a value by javascript upon selected a autocomplete suggestion on the client side, which can then be read server side on postback.
I add the "extra" HiddenField by overriding the control's OnInit event
private HiddenField hf = new HiddenField();
protected override void OnInit(EventArgs e) {
hf.ID = base.UniqueID + "_hf";
this.Controls.Add(hf);
base.OnInit(e);
}
The control also extends a Value property
public string Value {
get { return hf.Value; }
set { hf.Value = value; }
}
And in the control's Render method (aside from all the other stuff) I do
protected override void Render(System.Web.UI.HtmlTextWriter writer) {
...
base.Render(writer);
hf.RenderControl(writer);
...
}
And then my problem:
On postbacks I am able to retrieve the control's Value property.
That is...for example, from a buttons click event I am able get the controls Value (assigned by javascript client side). No problem.
But when I try to do the exact same with on a webform with a master page the control's Value property is never populated on postback.
It's almost like the viewstate isn't restored or something.
Anywayz; I'm puzzled as to why the things works fine on a "normal" webform but fails when using a master page.
Why the difference.
Everything else works fine.
Any help or ideas would be greatly appreciated.