Search code examples
c#razordotnetnuke2sxcdnn9

How can I get a 2sxc Toolbar Button added that is a link to another page and does NOT open in a new tab/window?


In brief, I want a toolbar button that has a different color and icon that goes to another page with a URL param (name/value). Something like

https://myfabulo.us/about/staff/personId/333

Other than doing a .Info() I can't seem to figure out any way to have a button just be a link. Is there a way to use .Info() this and tweak it so that the link does NOT open in a new window? Or is there some other simple combination of options that lets me define a button that has a URL constructed from some params (data) or the current item?

I thought I was getting close, but the parameters do not seem to do what I thought they would do, setup variables:

@{
  var uiCode = new { 
    Icon = svgIcon,
    Title = "Assign Users",
    Color = "purple"
  };
  string baseUrl = "/tabid/176/"
}

here we are inside a foreach (var item in items):

  var tbEdit = Kit.Toolbar.Empty(item).Edit();

  <span class="mx-2"
    @((item.String("RuleType") == "users")
      ? tbEdit.Info(link: baseUrl, parameters: new { assignId = item.Id }, tweak: tb => tb.Ui(uiCode))
      : tbEdit
    )
  >
    @item.String("Name") 
  </span>

But that doesn't work because .Info() doesn't have an option for parameters. And if I prebuild the link:

  string linkTarget = Link.To(pageId: 176, parameters: $"assignId={item.Id}");

and then do

    ? tbEdit.Info(link: linkTarget, tweak: tb => tb.Ui(uiCode))

Then I get a button and the link works, BUT it opens in a new window and I cannot find a way to get it to not do that.

I just want a button that goes to another page with the option to add some URL params. Anyone know what I am missing?


Solution

  • The bad news: not possible in v16.

    The good news: will be available in v17 which should be released before x-mas. https://github.com/2sic/2sxc/issues/3229

    will be

    • .Info(link: "...") - no target means nothing special
    • .Info(link: "...", target: "_blank") - open in new window