asp.net - ASP 按钮不起作用

标签 asp.net .net sharepoint button

所以我尝试使用asp.net 在我公司的sharepoint 站点中插入一个按钮。该按钮显示正确,但当我单击它时无法使其转到某个页面。当我点击它时,它只会刷新页面。我希望它转到此链接... http://www.w3schools.com/ 。有人可以帮我解决这个问题吗?

    <WebPartPages:WikiContentWebpart frametype="none" chrometype="None" runat="server" partorder="1" __WebPartId="{9852E1FB-0E97-47D1-BC63-0A8D2D953F9D}" id="g_9852e1fb_0e97_47d1_bc63_0a8d2d953f9d">
        <content>
        <div>
            &nbsp;
            <asp:Button runat="server" Text="Add New Item" id="Button1" Font-Bold="True" onclick="window.location='http://www.w3schools.com/'"></asp:Button> </div>
        </content>
    </WebPartPages:WikiContentWebpart>

最佳答案

<asp:Button runat="server" Text="Add New Item" id="Button1" Font-Bold="True"
     OnClientClick="window.location='http://www.w3schools.com/'; return false;">   </asp:Button>

您需要更改两件事:

  1. 由于这是客户端处理程序,因此请使用 OnClientClick
  2. 设置位置后返回 false,以便不会触发默认事件(回发)。

关于asp.net - ASP 按钮不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11741104/

相关文章:

sharepoint - 自定义列表比较 Sharepoint 中的日期

c# - Path.GetTempFileName-目录名称无效

c# - 读取 ConfigurationSectionGroup 中的属性

asp.net - WCF + REST,增加 MaxStringContentLength

python - 想从 MS Access 升级到 .NET? Visual Studio ?

android - SharePoint - 在现有文件夹(在服务器上)内创建文件夹

asp.net - 从包含在母版页中的 aspx 的用户控件访问母版页控件

c# - NUnit 3 重试测试n次

c# - 线程并行调用、操作

javascript - 是否可以将删除/放置请求发送到 Azure AD 安全 api 或使用 aadHttpClientFactory 以字符串形式获取 jwt token