gpt4 book ai didi

c# - 如何从母版页知道它是否是默认页

转载 作者:行者123 更新时间:2023-11-30 20:50:54 25 4
gpt4 key购买 nike

我想在页面为 default.aspx 时调用一个 div,并在页面为非默认页面时同时调用同一个 div。我已经完成了类似的操作,但操作不正确。

<% if(string.Compare(Request.Url.LocalPath,"/default.aspx")==0 ||  string.Compare(Request.Url.LocalPath,"/") ==0)
{%>
<div class="temples" >
<% } %>
<% else
{ %>
<div class="temples" style="display:none";>
<% } %>

最佳答案

你可以这样尝试:

string s = this.Page.Request.FilePath;

这将从母版页中获取当前请求 URL

同时检查 IsMasterPage属性:

Gets a value that indicates whether or not a child element in the viewer should be used as a master page.

关于c# - 如何从母版页知道它是否是默认页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22163467/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com