【问题标题】:NavigateUrl="#" navigates to next page - ASP.Net HyperlinkNavigateUrl="#" 导航到下一页 - ASP.Net 超链接
【发布时间】:2016-09-20 00:11:45
【问题描述】:

我在 ASP.Net 中声明了以下超链接。

<asp:HyperLink ID="lblPostcode" runat="server" Text='<%# Eval("POSTCODE") %>' 
NavigateUrl="#" Target= "_blank"
onClick ='<%# String.Format("ViewGoolgeMap(\"{0}, {1}, {2}\")",Eval("ADDRESS").ToString(),Eval("TownCITY").ToString(),Eval("POSTCODE").ToString())%>' />

并遵循 javascript 方法,从上面的超链接调用。

function ViewGoolgeMap(pid) {

        window.open("https://www.google.co.uk/maps/place/" + pid + "", "Map" + pid, "width=500px,height=520px,left=20,top=20");

    }

实际结果是它正在打开弹出窗口,但在打开弹出窗口后,它导航到一个错误页面,说

HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.

必需的解决方案是它应该只打开弹出窗口。没有其他事情需要做。

非常感谢。

【问题讨论】:

    标签: javascript asp.net .net hyperlink


    【解决方案1】:

    onClick 处理程序中返回false 将停止页面执行href

    function ViewGoolgeMap(pid) {
        window.open("https://www.google.co.uk/maps/place/" + pid + "", "Map" + pid, "width=500px,height=520px,left=20,top=20");
     return false; //Changed here
    
        }
    

    【讨论】:

    • 您还应该在onclick 事件处理程序中返回该值:onclick='&lt;%# String.Format("return ViewGoolgeMap(...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-07
    • 2013-05-13
    • 2020-04-05
    相关资源
    最近更新 更多