user3247426
user3247426

Reputation: 127

how to know whether it is default page or not from master page

I want to call one div when the page is default.aspx and to call same div at the same time when the page is another page than default.I have done something like this but is not doing correctly.

<% 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";>
<% } %>

Upvotes: 2

Views: 134

Answers (2)

Rahul Tripathi
Rahul Tripathi

Reputation: 172468

You can try like this:

string s = this.Page.Request.FilePath;

This will get you the current request URL from within the master page

Also check the IsMasterPage property:

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

Upvotes: 2

cat916
cat916

Reputation: 1361

There is a property IsMasterPage to define whether your control element associated to master page. Below is a link to get more information.

DocumentViewerBase.IsMasterPage

Upvotes: 2

Related Questions