Hide a div based on certain pages

webstudent123

New Member
Hey all, I am trying to figure out how to hide a div in master layout (cms site) if the visitor enters the checkout process:

The site is based in aspx (network solutions)

The actual issue is we need to hide our facebook like button when the visitor enters the checkout process because it throws an 'insecure' site error to users in IE-

We were told by Net Sol's guy that we can somehow hide the whole div when in the checkout process.

I have been looking into how to do this with javascript and css but am having no luck-

Thanks in advance
 

PixelPusher

Super Moderator
Staff member
Well your in ASP.NET so you could just do this in the code behind. Gimme one sec and I will give you an example of how i have done something like this in the past.
 

PixelPusher

Super Moderator
Staff member
Ok so here is one method you use (bare in mind I do not know your site structure, pagenames etc). Create a asp:Literal and insert your FB like button script into it. In the code behind for your master page, inform the server when and when not to show this button (Literal).

ASPX MasterPage.Master
Code:
...
<asp:Literal runat="server" ID="FaceBookBtn" Visible="false">
   Script from Facebook for the "Like" button"</asp:Literal>
...

MasterPage.Master.cs (Code Behind)
Code:
...
protected void Page_Load(object sender, EventArgs e)
{
   if (pagename.StartsWith("~/checkout.aspx")) 
   {
      FaceBookBtn.Visible = false;
   }
   else 
   {
      FaceBookBtn.Visible = true;
   }
}
...

NOTE: The code above assumes that your checkout page is located in the root level directory of your site and has a pagename of "checkout".

Good luck!
 
Last edited:

webstudent123

New Member
quick question

for "creating an asp:Literal", do you mean create a function or a css div, sorry man, not super familiar with programming- Thanks
 

PixelPusher

Super Moderator
Staff member
for "creating an asp:Literal", do you mean create a function or a css div, sorry man, not super familiar with programming- Thanks

The "<asp:Literal></asp:Literal>" will be in the html markup of the page, aspx page.

The function/statement (if, else) will be inserted in the code behind.

What software are you using? Microsoft Visual Studio?
 
Top