Save member in Admin UI clears all properties values
Hi there,
I created custom usercontrols (ascx) and added them as DataTypes so I could use them as properties in the Member Profile.
Everything works fine when the user registers or edits his profile in the page I built for that purpose, but when I save their profile in the Admin UI, when trying to add a new role to a specific user, all the profile properties are overwritten with empty values.
The controls are simply, except for one that uploads a photo using ajax without postback, but that's not the problem.
I really need the ability to add and remove roles to users, without deleting their profile properies...
I'm I doing something wrong?
Here's the code for one of the DataTypes I created. It's a dropdownlist that shows a textbox when the user selects the Other option. You can imagine the ascx... :)
Do I need to add any special method for the Admin UI editing?
What happens when you set a Breakpoint on value property during load and save, I guess something is wrong in there. Again attach a debugger and step throuh the code.
I debugged one of the controls and, when loading, everything works as expected: the property set is activated, and the value is set in ddlOption and rendered as supposed! (it hits the page load method after setting the property value)
When saving, the page load runs before the get of the property, and the value of the ddlOption returns empty.
In saving, the if(Page.IsPostBack) was false and it was never executed, but that's not the problem, because the ddlOption returns it value as an empty string...
It renders correctly, but when saving the ddl is empty. This remind me a little bit of DNN where the page load cycle overrides all properties and we need to manually create a "ViewState" to save all controls state...
Do I need to do something like that or there is an easier way?
What you should do is move the logic you have in the Page_Load event to either the getter of the Value property, or create a seperate method and call that in the getter of the value property. If you are doing stuff in the page_load it could be that in a later stage the viewstate is restored (not related to Umbraco or dnn it's just how asp.net works) then all kind of weird things can occur for example index_changed doesn't fire because for asp.net it seems nothing changed etc..
There's no need to have nothing in the PageLoad... Umbraco automatically get's the property value and we can bind it to the ddl inside...
All the examples I found (like this http://forum.umbraco.org/yaf_postst5322_custom-data-type.aspx) always bind the value to the control in the page load... And it works with custom pages to manage those properties but not in the Umbraco Admin UI...
Once again thanks a lot! ;)
Oh! Just one more thing... Can I bother you to help me find the answer for my last post in this thread? I bet it's just one more little thing... :/
Save member in Admin UI clears all properties values
Hi there,
I created custom usercontrols (ascx) and added them as DataTypes so I could use them as properties in the Member Profile.
Everything works fine when the user registers or edits his profile in the page I built for that purpose, but when I save their profile in the Admin UI, when trying to add a new role to a specific user, all the profile properties are overwritten with empty values.
The controls are simply, except for one that uploads a photo using ajax without postback, but that's not the problem.
I really need the ability to add and remove roles to users, without deleting their profile properies...
I'm I doing something wrong?
Here's the code for one of the DataTypes I created. It's a dropdownlist that shows a textbox when the user selects the Other option. You can imagine the ascx... :)
Do I need to add any special method for the Admin UI editing?
What happens when you set a Breakpoint on value property during load and save, I guess something is wrong in there. Again attach a debugger and step throuh the code.
Cheers,
Richard
Hi Richard, thanks for your answer and help!
I debugged one of the controls and, when loading, everything works as expected: the property set is activated, and the value is set in ddlOption and rendered as supposed! (it hits the page load method after setting the property value)
When saving, the page load runs before the get of the property, and the value of the ddlOption returns empty.
In saving, the if (Page.IsPostBack) was false and it was never executed, but that's not the problem, because the ddlOption returns it value as an empty string...
It renders correctly, but when saving the ddl is empty. This remind me a little bit of DNN where the page load cycle overrides all properties and we need to manually create a "ViewState" to save all controls state...
Do I need to do something like that or there is an easier way?
Thanks again!
Oh now I see,
What you should do is move the logic you have in the Page_Load event to either the getter of the Value property, or create a seperate method and call that in the getter of the value property. If you are doing stuff in the page_load it could be that in a later stage the viewstate is restored (not related to Umbraco or dnn it's just how asp.net works) then all kind of weird things can occur for example index_changed doesn't fire because for asp.net it seems nothing changed etc..
Cheers,
Richard
Geeeeez thanks!
I got it working now!
There's no need to have nothing in the PageLoad... Umbraco automatically get's the property value and we can bind it to the ddl inside...
All the examples I found (like this http://forum.umbraco.org/yaf_postst5322_custom-data-type.aspx) always bind the value to the control in the page load... And it works with custom pages to manage those properties but not in the Umbraco Admin UI...
Once again thanks a lot! ;)
Oh! Just one more thing... Can I bother you to help me find the answer for my last post in this thread? I bet it's just one more little thing... :/
http://our.umbraco.org/forum/ourumb-dev-forum/bugs/13287-Umbraco-Admin-UI-not-showing-Tree-Nodes-thumbnail
is working on a reply...