CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 4/12/2008 5:44:31 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 7 Views: 69 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
8 Items, 1 Pages 1 |< << Go >> >|
caijinjing
Asp.Net User
masterpage4/12/2008 5:44:31 PM

0/0

Hi all

I set one picture as the background of masterpage,

but I created a sub-folder in my application, I got one page  inherit from master page, the picture on master page does not display ??/

 Tongue Tied

mbanavige
Asp.Net User
Re: masterpage4/12/2008 5:52:07 PM

0/0

sounds like your having the same problem as in this thread: http://forums.asp.net/t/1246860.aspx

using a runat=server control with a root relative image path ( ~/ ) should fix you right up.


Mike Banavige
~~~~~~~~~~~~
Dont forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
caijinjing
Asp.Net User
Re: masterpage4/12/2008 6:34:42 PM

0/0

Thank you so much

 

That is the perfect solution to fix this problem


 But I need to set the picture as background so that other stuff could display on it

this solution is to display picture not as background.Sad
 

mbanavige
Asp.Net User
Re: masterpage4/12/2008 8:00:59 PM

0/0

if you are setting a background image, then i would recommend using a stylesheet (css)

the images pulled by a stylesheet can be referred to in that stylesheet relative to where the stylesheet exists in your folder structure. then linking in the stylesheet to your master page would be done in that root relative manner that i referred to.

in this way, your pages can always find the stylesheet regardless of whether the pages are stored in subfolder or not and the stylesheet will pull its images base on where the stylesheet was stored and not based on where the page is being pulled from.


Mike Banavige
~~~~~~~~~~~~
Dont forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
CharlesF
Asp.Net User
Re: masterpage4/12/2008 8:16:58 PM

0/0

Did you try a fully-qualified path in your CSS background image definition?

For example, instead of url(myimage.gif); try url(http://wwwmysite.com/myappdir/images/myimage.gif)

You could also try url(/myappdir/images/myimage.gif) if your app will always be installed in "/myappdir/"

For more info about CSS background images... http://www.w3schools.com/css/pr_background-image.asp

Another option might be to generate the CSS style tag on the fly within your master page onload event. That way you could use ResolveURL and utilize the tilde ~/ in your URL. ResolveURL would resolve it to the correct URL on the fly for each page.

They didn't make it easy to add a style tag (like you can for a script tag) to the <head> section in code-behind though.

One technique I can think of, off the top of my head, is to add the runat="server" and an id="myHead" attributes to the <head> tag.This way you can access the HTMLHead object in your masterpage code behind and then utilize the methods and properties of that class in order to add a <script> tag to it.

The theory is that you would create a new GenericHTMLControl object in code and setting the .TagName property of this generic control object to "style" and then add a "type" attribute by using the .Attributes.Add method... e.g. myhead.Attributes.Add("type","text/css")

I would then dynamically generate the CSS code using a stringbuilder (remembering to use the ResolveURL method when I get to the portion that outputs the CSS code for the URL of the background image). Then I would set the GenericHTMLControl's .InnerHTML property to the stringbuilder.toString() value. e.g. mygenericcontrol.InnerHTML = myStringBuilder.ToString()

Here's an example of what you might put in your masterpages code-behind "onLoad" event: (assuming you've added the id="myHead" and runat="server" to your head tag in design view)

        Dim myStyleTag As HtmlGenericControl = New HtmlGenericControl()
        myStyleTag.TagName = "style"
        myStyleTag.Attributes.Add("type", "text/css")

        Dim mySB As StringBuilder = New StringBuilder()
        mySB.AppendLine("body {")
        mySB.AppendLine("  background-image: url(" & ResolveUrl("~/images/mybackground.gif") & ");")
        mySB.AppendLine("}")
        myStyleTag.InnerHtml = mySB.ToString()

        myhead.Controls.Add(myStyleTag)
 
-Charles

p.s. If this post provides your answer, please remember to mark it.
mbanavige
Asp.Net User
Re: masterpage4/12/2008 8:28:32 PM

0/0

it doesnt need to get too complicated.  imagine the following link in the head section of a masterpage

<link runat="server" 
      id="csslnk1" 
      href="~/MyStyles.css" 
      rel="stylesheet" type="text/css" />
regardless of what page calls for that masterpage, the masterpage can find that stylesheet in the root folder of the web app.  you could also use a subfolder too if that's what you prefer.

now lets assume that we have an images subfolder with all our images. Inside the stylesheet, we can add a selector to set the background-image of our page like this:

body {background-image: url(images/myImage.gif);}

since the stylesheet was pulled from the root folder of the app, it can correctly find the images folder.  the particular folder that the page is being rendered from is no longer part of the equation.  the image path in the css is relative to where the stylesheet was stored.

 


Mike Banavige
~~~~~~~~~~~~
Dont forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
CharlesF
Asp.Net User
Re: masterpage4/13/2008 6:06:48 AM

0/0

You're right. If you don't need the flexibility to be able to change the image used in your background, your method is easier.

Me, I like to be able to change the background image for various roles, such as administrators. But that's totally a personal preference thing. Wink

 


-Charles

p.s. If this post provides your answer, please remember to mark it.
mod84
Asp.Net User
Re: masterpage4/13/2008 6:10:27 AM

0/0

thats actually a cool idea. its pretty simple, but would definitely look sharp 


EXPERT .NET DEVELOPER
8 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Beginning ASP.NET 2.0 with C# Authors: Chris Hart, John Kauffman, David Sussman, Chris Ullman, Pages: 735, Published: 2006
Professional ASP.NET 2.0 Authors: Bill Evjen, Scott Hanselman, Farhan Muhammad, Srinivasa Sivakumar, Devin Rader, Pages: 1253, Published: 2005
Beginning ASP.NET 2.0 in VB 2005: From Novice to Professional Authors: Matthew MacDonald, Pages: 1063, Published: 2006
ASP.NET 2.0 Website Programming: Problem-design-solution Authors: Marco Bellinaso, Pages: 576, Published: 2006
Beginning ASP.NET 2.0 Authors: Chris Hart, John Kauffman, Chris Ullman, David Sussman, Pages: 759, Published: 2005
Pro ASP.NET 2.0 in VB 2005: From Professional to Expert Authors: Laurence Moroney, Matthew MacDonald, Pages: 1253, Published: 2006
Pro ASP.NET 2.0 in C# 2005 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1255, Published: 2005
Beginning ASP.NET 3.5 in C# 2008: From Novice to Professional Authors: Matthew MacDonald, Pages: 954, Published: 2007
Beginning ASP.NET 3.5 in VB 9.0: From Novice to Professional Authors: Matthew MacDonald, Pages: 1149, Published: 2007
Professional C# 2005 with .NET 3.0 Authors: Christian Nagel, Bill Evjen, Jay Glynn, Karli Watson, Morgan Skinner, Pages: 1748, Published: 2007

Web:
ASP.NET Master Pages Overview A single master page defines the look and feel and standard behavior ... <%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %> ...
MasterPage Class (System.Web.UI) Minimal)> _ Public Class MasterPage _ Inherits UserControl ... The MasterPage class is associated with files that have a .master extension. ...
ASP.NET.4GuysFromRolla.com: A Sneak Peak at MasterPages in ASP.NET 2.0 Jan 5, 2005 ... This article, by Scott Mitchell, looks at one of the many exciting features of ASP.NET 2.0 - MasterPages. MasterPages provide a simple means ...
Mark Arend : Master Page stsadm commands Jan 24, 2008 ... Have you ever wanted to use stsadm to view or manipulate a site's master page? Unfortunately there are no default commands to do so.
Introducing ASP.NET 2.0 Master Pages Pages that use a master page to define the layout may place content only in the ... NET Whidbey, you create a master page by opening the Add New Item dialog ...
Data Tutorial #2: Building our Master Page and Site Navigation ... NET 2.0 Master Page feature. And my site and link structure is nicely encapsulated by ..... Have you run into any problems with MasterPages, SiteMap and the ...
VS 2008 Nested Master Page Support - ScottGu's Blog NET and its nested Master Page support is really easy with VS 2008. ..... I do think that almost every web site should use nested masterpages. ...
Master Page MasterPage of Facts about Poland, maps of Poland and information for Poland. The Master Page for travel and business oppportunities with Polish products and ...
ASPAlliance.com : The #1 ASP.NET Developer Community : Paul ... This article demos an improved version of MasterPages that has designer support, ... To use the MasterPage Template you start by creating an empty ASP. ...
CodeProject: An Extensible Master-Page Framework for ASP.NET 1.1 ... Development of a framework for master-pages using ASP.NET and C#.; Author: Shams Mukhtar; Section: Design and Architecture; Chapter: Development Lifecycle.

Videos:
Modify a Master Page in SharePoint Designer 2007 In this video you will learn how to use SharePoint Designer to modify and re-brand a SharePoint default.master page. For more information, see http:...
master page master page
ZyWeb - Master Page Tutorial A tutorial for ZyWeb.com that explains how to create a Master Page, from which you can copy the layout and theme to your other pages and reduce the a...
RapidWeaver Screencast: The Blocks Plugin's Master Page RapidWeaver Classroom presents a tutorial on using the Master Page as a part of the Blocks plugin for RapidWeaver.
Rock Cruz interviews Master Page and Sean Eichenberg Rock roams the Martial Art Competitions and Exhibitions at The Louisville Convention Center in Louisville, KY Shooting and editing by Shooter Russell
Create Pages From a Master Page in SharePoint Designer 2007 In this video you will learn how to use SharePoint Designer to create a new SharePoint page based on a specific master page. For more information, s...
RCxhet - Como crear un master page ASP .net Part 1 Crear Master Page Code Beside Tabla invisible sin bordes Bordes de Mi pagina Espacio entre celdas ContentPlaceHolder Insertar Imagenes en mi web Agre...
Creación de un MasterPage Creación de un MasterPage
MasterPage Ejemplo muy simple de como crear una MasterPage
Asp con un master page aplicacion de asp con un master page




Search This Site:










timer on controls in master page won't update on member pages

sitemapnode problem

how do i make the whole menu cell clickable?

master pages for multiple applications

top menu with one style when select even when a sub menuitem selected

callbacks in whidbey!

menu control html code is huge

treeview directory listing on file share

master pages - contentplaceholder control size in visual studio 2005 design mode

broken links when using masterpage

sitemappath renders nothing

i cannot create master page after installing .net 2.0

asp:menu aligned left in firefox. how do i set the alignment to right?

applying a skin to loginview control

create a page or a usercontrol?

the master page does not allow the child page to grow down

problem with content place holder !!?

adding javascript to a menu item in a menu control

localization with masterpage

javascript and master page

onpropertychange javascript master page

need advice on how to implement menu

microsoft (menu) server control source code?

masterpages, form-tags, etc....

positioning issues

css and <div>

submenus become visible as i apply theme to a page having a master page

contentplaceholder in masterpage header

building menus dynamically

reload masterpage after menuitem_click

  Privacy | Contact Us
All Times Are GMT