Although the value (ie. teaser) is updated, it is not showing it on the screen, I have to refresh the screen (by reclicking on the Document) to show the new value.
I tried doing it on BeforeSave, same thing.
How can I update a value on Save, and have it shown on the screen? Thanks in advance.
Maybe an annoying answer. But why are you using umbraco events to dome some job one would normally do when rendering the actual content to the template using razor or other methods.
I don't think there is any (good) way to show the updated value, since I believe it loads from viewstate. You could possibly use some javascript or a custom datatype for the teaser field that reloads on each postback..
I do agree with Mathijs though, you should probably just handle this when you are rendering. If you want the option to override it you could use the teaser textbox value if it's not empty.
No Mathjis that's a good comment. And thanks Tom. I am new to Umbraco and I don't know how to override the render function. Could you tell me how to do it?
How are you currently displaying the Teaser text on your website? Via an umbraco:Item tag, or a macro (xslt or razor)?
If you're using an umbraco:Item tag currently, you'll probably need to use a macro instead so you can call your GetFirstFewWords function.
If you're using an XSLT macro, you can write a quick XSLT Extension method so that you can call the GetFirstFewWords function from XSLT. Basically all you have to do is decorate your class with [XsltExtension] - here's a quick article on it. Then you can call it from XSLT with something like <xsl:value-of select="yourextension:GetFirstFewWords($currentPage/bodyText)"/>.
If you're using Razor, I can't really help you much :)
Ah... is that what you guys meant? I can do anything I want on the front end, true.
But what I wanted is to give the admin a default Teaser which they can then edit. Currently they have to reclick the document on the tree to have the default Teaser displayed.
Document.AfterSave is not showing the new value
I have this method
Although the value (ie. teaser) is updated, it is not showing it on the screen, I have to refresh the screen (by reclicking on the Document) to show the new value.
I tried doing it on BeforeSave, same thing.
How can I update a value on Save, and have it shown on the screen? Thanks in advance.
Maybe an annoying answer. But why are you using umbraco events to dome some job one would normally do when rendering the actual content to the template using razor or other methods.
Mathijs
I don't think there is any (good) way to show the updated value, since I believe it loads from viewstate. You could possibly use some javascript or a custom datatype for the teaser field that reloads on each postback..
I do agree with Mathijs though, you should probably just handle this when you are rendering. If you want the option to override it you could use the teaser textbox value if it's not empty.
No Mathjis that's a good comment. And thanks Tom. I am new to Umbraco and I don't know how to override the render function. Could you tell me how to do it?
Anyone else know how to override the render function as Mathjis said....?
Hi Hardi,
How are you currently displaying the Teaser text on your website? Via an umbraco:Item tag, or a macro (xslt or razor)?
If you're using an umbraco:Item tag currently, you'll probably need to use a macro instead so you can call your GetFirstFewWords function.
If you're using an XSLT macro, you can write a quick XSLT Extension method so that you can call the GetFirstFewWords function from XSLT. Basically all you have to do is decorate your class with [XsltExtension] - here's a quick article on it. Then you can call it from XSLT with something like <xsl:value-of select="yourextension:GetFirstFewWords($currentPage/bodyText)"/>.
If you're using Razor, I can't really help you much :)
-Tom
Ah... is that what you guys meant? I can do anything I want on the front end, true.
But what I wanted is to give the admin a default Teaser which they can then edit. Currently they have to reclick the document on the tree to have the default Teaser displayed.
Thanks Tom :)
is working on a reply...