Congrats, you have done the hard work implementing this feature but I can't tell my users that the amazing improvement of this version is that they are now able to copy and paste the url. So, how could I achieve implementing an action that finally open a view (current or another) into a new browser tab?
How to open the current View in a new web browser tab using a custom Action when EnableMultipleBrowserTabsSupport = True
Answers approved by DevExpress Support
Hello José,
>>So, how could I achieve implementing an action that finally open a view (current or another) into a new browser tab?
Even though we do not currently provide good solutions for this particular task, our team will keep your request in mind regarding future updates of our framework.
UPDATED:
To duplicate the current View in a new browser tab using an Action, consider one of the two approaches below:
C#using System.Web;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.Web;
using DevExpress.Persistent.Base;
namespace MainDemo.Module.Web {
public partial class T464375 : ViewController {
public T464375() {
var duplicateCurrentViewAction = new SimpleAction(this, "DuplicateViewInBrowser", PredefinedCategory.Unspecified);
//Approach #1. The most simple and straightforward way using client-side API.
//1.1. Opens a View in the main form template with navigation, logo, etc.
duplicateCurrentViewAction.SetClientScript("window.open(window.location.href,'_blank');", false);
//1.2. Opens a View in the dialog form template.
//duplicateCurrentViewAction.SetClientScript(string.Format("window.open('{0}'+ window.location.hash, '_blank');", WebApplication.PopupWindowTemplatePage), false);
//Approach #2. Using the server-side API (e.g., when you have SingleChoiceAction and cannot use the 1st approach).
//duplicateCurrentViewAction.Execute += (s, e) => {
// string fullViewURL = string.Format("{0}#{1}", HttpContext.Current.Request.Url.AbsoluteUri, ((WebApplication)Application).RequestManager.GetQueryString(View.CreateShortcut()));
// WebWindow.CurrentRequestWindow.RegisterStartupScript(duplicateCurrentViewAction.Id, string.Format("window.open('{0}','_blank');", fullViewURL));
//};
}
}
}
I have also blogged about this feature to collect more user feedback: http://dennisgaravsky.blogspot.com/2017/01/follow-up-on-enablemultiplebrowsertabss.html
See Also:
How to add a hyperlink to a new object to a standard aspx page
@JAMEL HABIB:
I've created a separate ticket on your behalf (T471084: How to show the opened detail view without navigation pane and others in a new web browser tab). It has been placed in our processing queue and will be answered shortly.
Hi José Enrique :
can you tell me which event are you using these code?
thanks!
C#DevExpress.ExpressApp.Web.WebApplication webApplication = (WebApplication)Application;
DevExpress.ExpressApp.Web.IHttpRequestManager requestManager = webApplication.RequestManager;
IObjectSpace os = Application.CreateObjectSpace();
DetailView detail = Application.CreateDetailView(os, Application.FindDetailViewId(e.CurrentObject.GetType()), true, os.GetObject(e.CurrentObject));
DevExpress.ExpressApp.ViewShortcut shortcut = detail.CreateShortcut();
string fullViewURL = string.Format("{0}#{1}", System.Web.HttpContext.Current.Request.Url.AbsoluteUri, requestManager.GetQueryString(shortcut));
WebWindow.CurrentRequestWindow.RegisterStartupScript("", "window.open('"+ fullViewURL + "','_blank');");
@he dandan: In my answer above you can see that this code is used inside the Execute event handler of a custom Action.