Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UriHelper NavigateTo new tab #8703

Closed
TFTomSun opened this issue Mar 21, 2019 · 3 comments
Closed

UriHelper NavigateTo new tab #8703

TFTomSun opened this issue Mar 21, 2019 · 3 comments
Labels
area-blazor Includes: Blazor, Razor Components question

Comments

@TFTomSun
Copy link

Hello,

is it somehow possible (in Blazor) to programatically open a url in new tab?

Best regards,
Thomas

@muratg muratg added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Mar 21, 2019
@mkArtakMSFT
Copy link
Member

Thanks for contacting us, @TFTomSun.
@SteveSandersonMS is this something possible with pure Blazor, or should this be achieved with JSInterop for now?

@mkArtakMSFT mkArtakMSFT added question area-blazor Includes: Blazor, Razor Components labels Mar 21, 2019
@SteveSandersonMS
Copy link
Member

You'll need to use JS interop for this.

@TFTomSun
Copy link
Author

Just in case someone else come accross this post...

        public async Task NavigateToUrlAsync(string url, bool openInNewTab)
        {
            if (openInNewTab)
            {
              await JSRuntime.Current.InvokeAsync<object>("open",url,"_blank");
            }
            else
            {
                this.UriBuilder.NavigateTo(url);
            }
        }

@mkArtakMSFT mkArtakMSFT removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels May 9, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components question
Projects
None yet
Development

No branches or pull requests

4 participants