Some custom datatypes I've made alter the content of a node after clicking the save & publish button. However, since it's an afterSave handler, once the normal reload happens, the OLD values are still shown in the backoffice.
To make this a bit easier for the content editors, I do a response.redirect to the current URL on these datatypes. There's one little problem with that though: the active tab gets lost. Is there a way that I can maybe add tab to be activated to the url, like /umbraco/editContent.aspx?id=2625&tab=3 or something like that? Any other ideas?
I think with 4.5 it's possible, I made a client API for the tab control (which just wrapped the old client side methods).
It's not going to be an easy job, your data type needs to set a page load javascript event which finds the tab you need to navigate to and then invoke a click on it.
The ClientID of the TabView control, your DataType should be able to find it by walking up the control tree.
tabPageId
This is the client ID of the tab that you want to show (you can get this from the TabPage control's ClientID property + "_tab0" + the position in the array of TabPages). The DataType should be able to find this without a huge problem, you'll just need to walk the control tree a bit.
arrayOfTabPageIds
At least that's what I think this is, you'll have to experiment a bit. You *should* be able to work it out from the TabView control.
Like I said, it's not going to be easy to do the code, there'll be a lot of walking the control tree to find what you need. I've based this from the code in the TabView class (umbraco.controls project) .
In my case, I have a button on a datatype that performs some actions on the page's properties, then redirects back to editContent.aspx. In order to show a speechbubble I set a Session variable (needsResync) before doing the redirect, and check for this in the Page_Load Event. I was able to add the below code there to reset the tab:
First, before redirecting (on the button click code), grab the active tab ID and store in a session
TabView tv = (TabView)Page.Master.FindControl("body").FindControl("TabView1"); HttpContext.Current.Session["activeTab"] = this.Parent.Page.Request.Form[tv.ClientID + "_activetab"];
// Set a flag so we know to show bubble/reset tab HttpContext.Current.Session["needsResync"] = true;
On the Page_Load Event after the redirect
if (Convert.ToBoolean(HttpContext.Current.Session["needsResync"])) { // Other stuff .....
// Reset the active tab:
// Find the Tabview TabView tv = (TabView)Page.Master.FindControl("body").FindControl("TabView1");
// Create an array of the tabs to pass into setActiveTab string strTmp = ""; for (int i = 1; i <= tv.Controls.Count; i++) { if (i > 1) strTmp += ","; strTmp += "\"" + tv.ClientID + "_tab0" + i + "\""; }
Interesting approach Tom, unfortunately, I am using the default datatypes (in my case the Upload datatype for example) and I am dependent on the "Save" button in Umbraco. So the only way I can execute some code is in the AfterSave event handler, but I can't access the Page object like this in said event handler..
Bookmarked though, this might come in handy someday, thanks!!
Ooh, one hack I can think of: Make a new datatype that has some javascript that will detect clicks on tabs. Write the tab ID to a cookie and on page load, find the cookie and then set the active tab. It's a hack and requires a "dummy" datatype, but that might just be enough. I don't have time at the moment, but I will be trying this soon if nobody beats me to it.
Go to specific tab after refresh
Some custom datatypes I've made alter the content of a node after clicking the save & publish button. However, since it's an afterSave handler, once the normal reload happens, the OLD values are still shown in the backoffice.
To make this a bit easier for the content editors, I do a response.redirect to the current URL on these datatypes. There's one little problem with that though: the active tab gets lost. Is there a way that I can maybe add tab to be activated to the url, like /umbraco/editContent.aspx?id=2625&tab=3 or something like that? Any other ideas?
I think with 4.5 it's possible, I made a client API for the tab control (which just wrapped the old client side methods).
It's not going to be an easy job, your data type needs to set a page load javascript event which finds the tab you need to navigate to and then invoke a click on it.
I've seen some crazy javascript stuff from you recently, any new insites on how to go to a tab direcly? I'm no JS wizard..
Hah no Shan is the one who does the crazy JavaScript, mine is only insane ;).
It's actually not really JavaScript that you need to run, the problem is the server code you need write!
Now what you need is:
It's not in an assembly, it's a JavaScript method
Hey Sebastiaan,
Did you ever figure this one out? Looking to do the same and having issues finding the control ID's etc.
Thanks,
Tom
Unfortunately, it took way too much time to get my head around this, so I couldn't. If you find a solution I would love to know about it!
Did some digging and came up with the solution.
In my case, I have a button on a datatype that performs some actions on the page's properties, then redirects back to editContent.aspx. In order to show a speechbubble I set a Session variable (needsResync) before doing the redirect, and check for this in the Page_Load Event. I was able to add the below code there to reset the tab:
First, before redirecting (on the button click code), grab the active tab ID and store in a session
On the Page_Load Event after the redirect
Working great! Hope this helps someone
-Tom
Interesting approach Tom, unfortunately, I am using the default datatypes (in my case the Upload datatype for example) and I am dependent on the "Save" button in Umbraco. So the only way I can execute some code is in the AfterSave event handler, but I can't access the Page object like this in said event handler..
Bookmarked though, this might come in handy someday, thanks!!
Ooh, one hack I can think of: Make a new datatype that has some javascript that will detect clicks on tabs. Write the tab ID to a cookie and on page load, find the cookie and then set the active tab. It's a hack and requires a "dummy" datatype, but that might just be enough. I don't have time at the moment, but I will be trying this soon if nobody beats me to it.
is working on a reply...