Styles in aspx
Styles in aspx
Styles in aspx
Styles in aspx
Styles in aspx
Styles in aspx Styles in aspx Styles in aspx Styles in aspx Styles in aspx Styles in aspx Styles in aspx Styles in aspx
Styles in aspx Styles in aspx
Styles in aspx
Go Back  Xtreme Visual Basic Talk > > > Styles in aspx


Reply
 
Thread Tools Display Modes
  #1  
Old 07-16-2009, 01:04 PM
PrOpHeT's Avatar
PrOpHeTStyles in aspx PrOpHeT is offline
Hopelessly confused...

* Expert *
 
Join Date: Mar 2001
Location: Tyler, Tx.
Posts: 3,055
Default Styles in aspx


Given a simple htm page I want to change the scrollbar color for an iframe,

I know I have to set the style in the page that is the target of the iframe, not the page that contains it, this all works

Code:
<html>
<head>

<style type="text/css">

body {scrollbar-base-color:#151515;}

</style>

</head>
<body>
.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br></body>
(the breaks are to make it scroll)

Now the containing page
Code:
<html>
<head>

<iframe src=test.htm></iframe>
</head>
However if I put the style section in the head of my aspx page it will not like so...

Code:
<html>
<head>
<iframe src=http://briefcase.serveftp.net/widgits/cogito.aspx></iframe>
</head>
viewing the source of the page once loaded shows the style tag complete in the head section, but the scroll bars remain default...

any ideas on why?
__________________
When you earnestly believe you can compensate for a lack of skill by doubling your efforts, there's no end to what you can't do ;)

For the love of Gold...
Reply With Quote
  #2  
Old 07-16-2009, 07:21 PM
Targe Targe is offline
Contributor
 
Join Date: Nov 2006
Posts: 615
Default

Are you even loading the cogito.aspx page? Shouldn't it be:
Code:
<iframe src="http://briefcase.serveftp.net/widgits/cogito.aspx"></iframe>
Also, for proper XHTML markup, remember to close all br tags off like so:
Code:
<br />
Now, if the first thing I gave doesn't solve the issue, you can be happy to know that some browsers don't even support the scrollbar styling. I don't remember off-hand which ones don't, though. Could be the other problem.

However, with all this aside, it's possible the containing page is overriding the main page's style sheets. One thing you can do to figure this out is download Google Chrome, right click on the page, and select Inspect Element. It will open a box which you can then highlight the specifics of your HTML and check the styles of it. Things which have crosses through them are overridden styles. I use this when I do heavy CSS because something always goes wrong, especially when trying to get everything to look the same across browsers.

By the way, I really don't recommend using IFrames.
http://websitetips.com/articles/html/frames/

Edit: I just reread your post and am confused on something. Do you want the IFrame's bar to change styles or the main page? It matters on where the CSS style goes.
Reply With Quote
  #3  
Old 07-16-2009, 08:25 PM
PrOpHeT's Avatar
PrOpHeTStyles in aspx PrOpHeT is offline
Hopelessly confused...

* Expert *
 
Join Date: Mar 2001
Location: Tyler, Tx.
Posts: 3,055
Default

Yes, this was a dirty example, but the page is loading in the frame.

I also know the BR syntax, again a dirty example.

CSS on the main page does not affect the bars on the iframe, that is controlled from the page loaded in it.

I am not a fan of the iframe either, but I have to use it to embed my 3rd party content from my home server into my blog space

So the page loads and the style in the page gets ignored.

The whole scenario works perfect from htm pages, fails on aspx pages.
__________________
When you earnestly believe you can compensate for a lack of skill by doubling your efforts, there's no end to what you can't do ;)

For the love of Gold...
Reply With Quote
  #4  
Old 07-16-2009, 11:07 PM
Targe Targe is offline
Contributor
 
Join Date: Nov 2006
Posts: 615
Default

Have you tried loading the style sheet from code behind on the page load event? I've had some styles not get generated from being embedded. Never use IFrames so don't this specific issue, but seems related since you did say it works in htm and not aspx. Basically sounds like the server isn't rendering it for one reason or another, so force it to.
Reply With Quote
  #5  
Old 07-17-2009, 08:08 AM
PrOpHeT's Avatar
PrOpHeTStyles in aspx PrOpHeT is offline
Hopelessly confused...

* Expert *
 
Join Date: Mar 2001
Location: Tyler, Tx.
Posts: 3,055
Default

I follow what you are saying, but not sure how you mean...
__________________
When you earnestly believe you can compensate for a lack of skill by doubling your efforts, there's no end to what you can't do ;)

For the love of Gold...
Reply With Quote
  #6  
Old 07-17-2009, 03:20 PM
Targe Targe is offline
Contributor
 
Join Date: Nov 2006
Posts: 615
Default

Something like this:
Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
   ' Forces page to load the CSS
   Dim myHtmlLink As HtmlLink = New HtmlLink()

   myHtmlLink.Href = "YourCSSPath.css"
   myHtmlLink.Attributes.Add("rel", "stylesheet")
   myHtmlLink.Attributes.Add("type", "text/css")

   Page.Header.Controls.Add(myHtmlLink)
End Sub
Reply With Quote
  #7  
Old 07-18-2009, 10:36 AM
PrOpHeT's Avatar
PrOpHeTStyles in aspx PrOpHeT is offline
Hopelessly confused...

* Expert *
 
Join Date: Mar 2001
Location: Tyler, Tx.
Posts: 3,055
Default

Still no go...

given the following example...

Code:
<html>
<head>
<iframe src="http://briefcase.serveftp.net/widgits/cogito.aspx"></iframe>
</head>
CSS is in place, page applies code as you specified, but scrollbars do not change...
__________________
When you earnestly believe you can compensate for a lack of skill by doubling your efforts, there's no end to what you can't do ;)

For the love of Gold...
Reply With Quote
  #8  
Old 07-18-2009, 11:47 AM
Targe Targe is offline
Contributor
 
Join Date: Nov 2006
Posts: 615
Default

What browser are you viewing it on? Apparently Mozilla browsers don't render it and it's an IE thing.

You say you can render the scrollbar CSS by putting it in the main page directly? The IFrame control really shouldn't go in the head section. Plus, with the code I gave you, it will add the CSS to the head without the IFrame being there. That maaay be your issue. But if still no, try having the IFrame toggle a flag variable in the parent page to set those CSS styles. Basically, when the IFrame exists, it's page load event will send over a call for it's parent to go ahead and use it's scrollbar CSS. I thought you mentioned it works when you use it in the parent. This is a cheap workaround but I'm running out of ideas.
Reply With Quote
  #9  
Old 07-18-2009, 11:56 AM
PrOpHeT's Avatar
PrOpHeTStyles in aspx PrOpHeT is offline
Hopelessly confused...

* Expert *
 
Join Date: Mar 2001
Location: Tyler, Tx.
Posts: 3,055
Default

It is IE8,

sorry I typed it in the head without realizing, however it makes no difference when moved to body.

Code:
<html>
<head>

</head>
<body>
<iframe src="http://briefcase.serveftp.net/widgits/cogito.aspx"></iframe>
</body>
The main problem I have with all of this is if I do the exact same thing from a HTM page it works. If I put the style in the main page it is ignored on the page in the iframe, makes no difference if it is there or not, iframe looks the same, however when I put the style in the page that the iframe loads it works, provided it is an HTML page, not asp.net.

Doing it on an ASPX it does not, same test platform....
__________________
When you earnestly believe you can compensate for a lack of skill by doubling your efforts, there's no end to what you can't do ;)

For the love of Gold...
Reply With Quote
  #10  
Old 07-18-2009, 01:16 PM
Targe Targe is offline
Contributor
 
Join Date: Nov 2006
Posts: 615
Default

You used the page load code I gave for the IFrame's load event right, not the parent page's event? If that really doesn't work then you may want to throw the IFrame out and go about this another way.

How about using something like a MasterPage instead? I'm basically out of ideas...

Buuut I got one more. Set an ID on the IFrame and on the main (parent) page's CSS, use the ID and scrollbar CSS to set that control's styles.

If that doesn't work then I really don't know what to tell you except I've never needed an IFrame. There are always alternatives. Probably not what you wanted to hear but don't know what other advice to give.
Reply With Quote
  #11  
Old 07-18-2009, 01:33 PM
PrOpHeT's Avatar
PrOpHeTStyles in aspx PrOpHeT is offline
Hopelessly confused...

* Expert *
 
Join Date: Mar 2001
Location: Tyler, Tx.
Posts: 3,055
Default

Yes it is the Iframe's page, not the master page.

I use the iframe because it allows me to embed pages from my home server into my blog.

The default scrollbar just looked ugly to me.

I guess I will let this one go, thank you however for all of your help.
__________________
When you earnestly believe you can compensate for a lack of skill by doubling your efforts, there's no end to what you can't do ;)

For the love of Gold...
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Styles in aspx
Styles in aspx
Styles in aspx Styles in aspx
Styles in aspx
Styles in aspx
Styles in aspx Styles in aspx Styles in aspx Styles in aspx Styles in aspx Styles in aspx Styles in aspx
Styles in aspx
Styles in aspx
 
Styles in aspx
Styles in aspx
 
-->