D
David.Morales
I have built a webcontrol that outputs a select/option html element amongst
other html. I had implemented IPostBackDataHandler differently and not had
the registerrequirespostback, but if a user selected an empty value in the
dropdown, no LoadPostData took place and the value was not saved. Now I am
using:
public bool LoadPostData(string postDataKey, NameValueCollection
postCollection)
{
if (EditMode){
string oldSelectedValue = SelectedValue;
if (postCollection.GetValues(postDataKey) == null) SelectedValue =
string.Empty;
else SelectedValue = postCollection.GetValues(postDataKey)[0]; //I have
overridden load/saveviewstate to store list in [1] which works fine
return oldSelectedValue != SelectedValue;
}
return false;
}
and added
if (Page != null) {Page.RegisterRequiresPostBack(this);}
to OnInit
(Edit mode is a property that changes the render from outputting a select or
just text.)
This now updates fine regardless of whether the selectedentry is a proper
value or an empty value. The problem is that now all values are lost when I
move from tab to tab (aspanels) on my page. All textboxes maintain their
values though, and if I set editmode to false, the text is remembered for
the combos (though in edit mode, just a label is rendered).
Any ideas/pointers etc would be appreciated.
Thanks
other html. I had implemented IPostBackDataHandler differently and not had
the registerrequirespostback, but if a user selected an empty value in the
dropdown, no LoadPostData took place and the value was not saved. Now I am
using:
public bool LoadPostData(string postDataKey, NameValueCollection
postCollection)
{
if (EditMode){
string oldSelectedValue = SelectedValue;
if (postCollection.GetValues(postDataKey) == null) SelectedValue =
string.Empty;
else SelectedValue = postCollection.GetValues(postDataKey)[0]; //I have
overridden load/saveviewstate to store list in [1] which works fine
return oldSelectedValue != SelectedValue;
}
return false;
}
and added
if (Page != null) {Page.RegisterRequiresPostBack(this);}
to OnInit
(Edit mode is a property that changes the render from outputting a select or
just text.)
This now updates fine regardless of whether the selectedentry is a proper
value or an empty value. The problem is that now all values are lost when I
move from tab to tab (aspanels) on my page. All textboxes maintain their
values though, and if I set editmode to false, the text is remembered for
the combos (though in edit mode, just a label is rendered).
Any ideas/pointers etc would be appreciated.
Thanks