IT TIP

새 탭에서 면도기 작업 링크를 여는 방법은 무엇입니까?

itqueen 2020. 11. 25. 21:48
반응형

새 탭에서 면도기 작업 링크를 여는 방법은 무엇입니까?


새 탭에서 링크를 열려고합니다 (면도기 형식이어야 함).

    <a href="@Url.Action("RunReport", "Performance", new { reportView = Model.ReportView.ToString() }, new { target = "_blank" })" type="submit" id="runReport" class="button Secondary">@Reports.RunReport</a>

그래도 작동하지 않습니다. 누구든지 이것을하는 방법을 알고 있습니까?


Url.Action ()에 대해 Html.ActionLink ()혼동하고있는 것 같습니다 . Url.Action에는 URL 만 반환하므로 Target을 설정하는 매개 변수가 없습니다.

현재 코드에 따라 앵커는 다음과 같아야합니다.

<a href="@Url.Action("RunReport", "Performance", new { reportView = Model.ReportView.ToString() })" 
   type="submit" 
   id="runReport" 
   target="_blank"
   class="button Secondary">
     @Reports.RunReport
</a>

를 사용 하고 그에 따라 HtmlHelper ActionLink설정하십시오 .RouteValuesHtmlAttributes

@Html.ActionLink(Reports.RunReport, "RunReport", new { controller = "Performance", reportView = Model.ReportView.ToString() }, new { target = "_blank" })

UrlHelper.Action(string,string,object,object)존재하지 않기 때문에 컴파일 되지 않습니다.

UrlHelper.Action<a>마크 업이 아닌 사용자가 제공 한 작업을 기반으로 URL 만 생성 합니다. HtmlAttribute (예 target="_blank": 새 탭에서 링크 열기) 를 추가하려면 다음 중 하나를 수행 할 수 있습니다.

  • <a>직접 요소에 대상 속성을 추가 하십시오.

    <a href="@Url.Action("RunReport", "Performance",
        new { reportView = Model.ReportView.ToString() })",
        target = "_blank" type="submit" id="runReport" class="button Secondary">
        @Reports.RunReport
    </a>
    
  • Html.ActionLink를 사용하여 <a>마크 업 요소 를 생성합니다 .

    @Html.ActionLink("Report View", "RunReport", null, new { target = "_blank" })
    

목표가 ActionLink 도우미를 사용하고 새 탭을 여는 것이라면 :

@Html.ActionLink("New tab please", "Home", null , new { target = "_blank" })

@Html.ActionLink("New tab please", "Home", Nothing, New With {Key .target = "_blank"})

명명 된 인수 사용 :

@Html.ActionLink(linkText: "TestTab", actionName: "TestAction", controllerName: "TestController", routeValues: null, htmlAttributes: new { target = "_blank"})

에 대한

@ Url.Action

<a href="@Url.Action("Action", "Controller")" target="_blank">Link Text</a>

@Html.ActionLink(
"Pay Now",
"Add",
"Payment",
new { @id = 1 },htmlAttributes:new { @class="btn btn-success",@target= "_blank" } )

각도 매개 변수가있는 asp.net mvc ActionLink 새 탭

<a  target="_blank" class="btn" data-ng-href="@Url.Action("RunReport", "Performance")?hotelCode={{hotel.code}}">Select Room</a>

당신은 it't을 설정하는 type것처럼 submit. 즉, 브라우저는 <form>데이터를 서버에 게시해야 합니다.

사실 태그에는 w3schools 에 따라 유형 속성이 없습니다 .

그래서 원격 type속성과 그것은 당신을 위해 작동합니다.


<a href="@Url.Action("RunReport", "Performance", new { reportView = Model.ReportView.ToString() })" type="submit" id="runReport" target="_blank" class="button Secondary"> @Reports.RunReport </a>

참고 URL : https://stackoverflow.com/questions/10851860/how-to-have-aa-razor-action-link-open-in-a-new-tab

반응형