This issue might be very simple to solve, but i simply cannot figure out how.
I have an ultra simple datatype: The only thing it does is extracting the name of the person which last edited the current node and puts the name in a label.
I have made a new datatype - LastEdited which uses the 'Umbraco Usercontrol Wrapper' and of course the simple usercontrol i have implemented.
I have then added the LastEdited datatype on one of my document types on the 'Genereic Properties' tab.
The problem is that the LastEdited datatype is not updated instantly when i save and publish the node. I have to click on another node and click back to the first one before the datatype is updated.
Does anybody have a work around for this one. Could imagine that this problem is a 'classic' and many of you out there must have had the same issue - but i have not found anything helpfull searching on our and google.
Normally you would have a method for when the control is initialized (this is probably what you have now) but also another method for when the control/datatype is being saved.
If you have some code to show, we can work on it from there ;)
I don't think I have used the IUsercontrolDataEditor before, but right now you only update your label if the page is not requested with a postback. Since saving the page triggers a postback, removing your if-statement should solve your problem ;)
First of all, you should probably use Document or the new Content api depending on the Umbraco version. Using Node, you will only get info from the last published version, right?
Anyways, did a quick test. I'm not entirely sure what is happening where, but it appears to be a matter of getting the data later in the page event cycle, good old WebForms.
public partial class LastEditedTest : UserControl, IUsercontrolDataEditor
{
protected override void OnPreRender(EventArgs e)
{
var nodeid = Request.QueryString["id"];
var currentDocument = new Document(Convert.ToInt32(nodeid));
LastEditedLabel.Text = "Denne node er sidst redigeret af: " + currentDocument.Writer.Name;
base.OnPreRender(e);
}
public object value { get; set; }
}
Updating usercontrol datatype on save event
Hi All!
This issue might be very simple to solve, but i simply cannot figure out how.
I have an ultra simple datatype: The only thing it does is extracting the name of the person which last edited the current node and puts the name in a label.
I have made a new datatype - LastEdited which uses the 'Umbraco Usercontrol Wrapper' and of course the simple usercontrol i have implemented.
I have then added the LastEdited datatype on one of my document types on the 'Genereic Properties' tab.
The problem is that the LastEdited datatype is not updated instantly when i save and publish the node. I have to click on another node and click back to the first one before the datatype is updated.
Does anybody have a work around for this one. Could imagine that this problem is a 'classic' and many of you out there must have had the same issue - but i have not found anything helpfull searching on our and google.
Thanks in advance!
Normally you would have a method for when the control is initialized (this is probably what you have now) but also another method for when the control/datatype is being saved.
If you have some code to show, we can work on it from there ;)
Hi Anders
This is the code
Thanks!
I don't think I have used the IUsercontrolDataEditor before, but right now you only update your label if the page is not requested with a postback. Since saving the page triggers a postback, removing your if-statement should solve your problem ;)
I have tried without the postback check also - it doesn't change anything.
Hi Emil
First of all, you should probably use Document or the new Content api depending on the Umbraco version. Using Node, you will only get info from the last published version, right?
Anyways, did a quick test. I'm not entirely sure what is happening where, but it appears to be a matter of getting the data later in the page event cycle, good old WebForms.
This works on my machine at least :)
Cheers
Mads
is working on a reply...