如何从其他页面重定向到masterpage.master [英] How to redirect to masterpage.master from other pages
问题描述
在我的项目中,我想使用'responce redirect'从其他页面转到主页。在母版页中,我有一个按钮'BtnHome',点击事件名为OnClick =BtnHomeClick。
当我使用下面的代码并单击主页按钮时,它会显示:'类型您请求的页面未被提供,因为它已被明确禁止。扩展程序.master可能不正确。请查看下面的网址,确保拼写正确。'
以下我提交代码:
In my project I want to go to Home page from other page using 'responce redirect'. In master page I have the button 'BtnHome' with a click event named as OnClick="BtnHomeClick".
When I use the following code and click the 'Home' button , it says :'The type of page you have requested is not served because it has been explicitly forbidden. The extension '.master' may be incorrect. Please review the URL below and make sure that it is spelled correctly.'
Hereunder I submit the code:
protected void BtnHomeClick(object sender, EventArgs e)
{
Response.Redirect("~/MasterPage.master");
}
<asp:Button ID="BtnHome" runat = "server" Text='Home' Font-Size="Medium" PostBackUrl="~/MasterPage.master" OnClick="BtnHomeClick" Font-Bold="true" ForeColor="White" BackColor="Teal" CausesValidation="false"
style=" margin-top:16px; cursor:pointer; margin-left:225px" BorderStyle="None" > </asp:Button>
推荐答案
您无法导航到MasterPage。您应该考虑创建一个主页,作为母版页的内容页面并重定向到它。
You cant Navigate to a MasterPage. You should consider creating a Home page which serves as a content page of the Master Page and redirect to it.
这篇关于如何从其他页面重定向到masterpage.master的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!