Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Urban 1 post 71 karma points
    Sep 12, 2023 @ 09:16
    Urban
    0

    Opening a subpage on a new window

    I have a button on my main page that opens up a new window. It is generated using jsgrid and this is the function that is called when the button is clicked:

    let diagnosticTime = item.DiagnosticTime;
    let faultCodeDesc = item.FaultCodeDescription;
    let diagnosticKey = item.DiagnosticKey;
    let actionUrl = "@Html.Raw(Url.Action("Subwindow", "PopulationDetails", new {
                populationId = Model.Id,
                serialNo = Model.SerialNo,
                accountId = Model.AccountId,
                ownerId = Model.PSSRId,
                alertType = 1,
                url = HttpContext.Current.Request.Url.AbsoluteUri
            }))&faultDate=" + diagnosticTime + "&faultDesc=" + encodeURIComponent(faultCodeDesc) + "&diagnosticKey=" + diagnosticKey;
    
            window.open(actionUrl, "_blank", "width=1400, height=700");
    
            e.preventDefault();
            e.stopPropagation();
    

    The relevant parts are: Url.Action("Subwindow", "PopulationDetails" which calls a controller and this: window.open(actionUrl, "_blank", "width=1400, height=700"); which open up the new window. The problem I have, is that the url of the new window is (localhost)/umbraco/Surface/PopulationDetails/Subwindow, but I need it to be (localhost)/portal/condition-monitoring/population-details-subwindow. How can I control that? Do I manually change the url or is there a better way? Here's the controller that returns the view for the new window:

    public ActionResult Subwindow(
    Guid populationId,
    string serialNo,
    Guid accountId,
    string diagnosticKey,
    string ownerId,
    DateTime faultDate,
    string faultDesc,
    int alertType,
    string url,
    string sosStatus = "") {
    
    
    int sosAlertPriority = 0;
    if (sosStatus != ""){
        switch (sosStatus){
            case "AR":
                sosAlertPriority = 3;
                break;
            case "MC":
                sosAlertPriority = 2;
                break;
            case "NAR":
                sosAlertPriority = 1; 
                break;
        }
    } ...
    
    ...
    var model = new CmAlertViewModel
    {
        Population = populationId,
        SerialNo = serialNo,
        AccountId = accountId,
        AlertName = alertName,
        AlertPriority = alertPriority,
        OwnerId = Guid.Parse(ownerId),
        FaultDate = faultDate,      
        FaultDescription = faultDesc,
        PortalURL = url,
        AlertType = alertType
    };
    return View("~/Views/PopulationDetailsSubwindow.cshtml", model);}
    

    Also, I checked the content of the PortalURL when the new window is opening using a debugger and the url is correct (the one I want the new window to open into)

Please Sign in or register to post replies

Write your reply to:

Draft