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.web_forms Tags:
Item Type: NewsGroup Date Entered: 1/30/2004 10:35:20 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 6 Views: 1 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
7 Items, 1 Pages 1 |< << Go >> >|
jackub
Asp.Net User
Changing Page Background from a User Control1/30/2004 10:35:20 PM

0/0

Simple enough!

I want to place a user control on a page and in that control i want to change the background color of the parent page. This should be very simple to do, but it's got me stumped .. help


Thanks
oxycan
Asp.Net User
Re: Changing Page Background from a User Control1/30/2004 11:24:00 PM

0/0


public class Control11 : System.Web.UI.UserControl
{
protected override void OnLoad(EventArgs e)
{
base.OnLoad (e);
this.Page.RegisterStartupScript("script", "<script language=\"Javascript\">document.bgColor = \"#00314A\";</script>");
}
}

Das Leben ist ein Born der Lust; aber wo das Gesindel mit trinkt, da sind alle Brunnen vergiftet.
SomeNewKid
Asp.Net User
Re: Changing Page Background from a User Control1/31/2004 12:16:26 AM

0/0

Hmmm ... dunno about that solution. There will be a marked "flash" from the default white colour to the Javascript-set colour.

Jackub, a User Control shouldn't really been setting any attributes of its containing page. It defeats the idea of encapsulation, which is very very fundamental to how ASP.NET works.

However, if you insist, the following does what you ask.



Here is the User Control. Please note that I have given it a classname attribute.
<%@ Control Language="VB" ClassName="MyControl9" %>

<script runat="server">
Public PreferredBackgroundColor As String = "#ffffcc"
</script>
This User Control has requested that the page background colour be a light yellow.



Here is its containing Page.
<%@ Page Language="VB" %>

<%@ Register TagPrefix="my" TagName="UserControl9" Src="mycontrol9.ascx" %>
<script runat="server">

Sub Page_Load( sender As Object, eArgs As EventArgs )
Dim DynamicUserControl As UserControl
DynamicUserControl = Page.LoadControl( "mycontrol9.ascx" )
MyPlaceholder.Controls.Add( DynamicUserControl )
Dim PageBackgroundColor = "#ffffff"
Try
PageBackgroundColor = CType( DynamicUserControl, MyControl9 ).PreferredBackgroundColor
Catch
End Try
Body.Attributes.Add( "bgcolor", PageBackgroundColor )
End Sub

</script>
<html>
<head>
</head>
<body id="body" runat="server">
<form runat="server">
<div style="border: solid 1px silver;padding: 20px;">
<asp:Placeholder id="MyPlaceholder" runat="server" />
</div>
</form>
</body>
</html>

Alister
oxycan
Asp.Net User
Re: Changing Page Background from a User Control1/31/2004 12:40:10 AM

0/0

Body??
Das Leben ist ein Born der Lust; aber wo das Gesindel mit trinkt, da sind alle Brunnen vergiftet.
SomeNewKid
Asp.Net User
Re: Changing Page Background from a User Control1/31/2004 12:55:37 AM

0/0

> Body??

Heheh. Yep.
<body id="body" runat="server">


Alister
oxycan
Asp.Net User
Re: Changing Page Background from a User Control1/31/2004 12:42:39 PM

0/0

Right. The good case-insensitive VB :)
Das Leben ist ein Born der Lust; aber wo das Gesindel mit trinkt, da sind alle Brunnen vergiftet.
SomeNewKid
Asp.Net User
Re: Changing Page Background from a User Control1/31/2004 3:56:33 PM

0/0

Naming the <body> element would work with C#, too.

Many developers will name both the <body> element and the <head> element.
<%@ Page Language="C#" inherits="test.codebehind2"  AutoEventWireup="false" %>

<html>
<head id="Head" runat="server">
</head>
<body id="Body" runat="server">
<form runat="server">
Did I say hello?
</form>
</body>
</html>


Then, in your code behind:
using System.Web.UI;

using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace test
{
public class codebehind2 : Page
{
protected HtmlGenericControl Head;
protected HtmlGenericControl Body;

override protected void OnInit(System.EventArgs e)
{
this.Load += new System.EventHandler(this.Page_Load);
base.OnInit(e);
}

private void Page_Load(object sender, System.EventArgs e)
{
string StartupScript = System.Environment.NewLine;
StartupScript += "<script type=\"text\\javascript\">" + System.Environment.NewLine;
StartupScript += "function Startup() { alert('hello'); }" + System.Environment.NewLine;
StartupScript += "</script>" + System.Environment.NewLine;

Head.Controls.Add( new LiteralControl( StartupScript ) );
Body.Attributes.Add( "onload", "Startup()" );
}

}

}

Alister
7 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Microsoft ASP.NET: Fast & Easy Web Development Authors: Nitin Pandey, NIIT (Firm), Pages: 398, Published: 2002
MCSD in a Nutshell: The Visual Basic Exams Authors: James D. Foxall, Pages: 632, Published: 2000
FrontPage 2003 All-in-One Desk Reference For Dummies: all-in-one desk reference Authors: John Paul Mueller, Pages: 792, Published: 2004
Integrated HTML and CSS: A Smarter, Faster Way to Learn Authors: Virginia DeBolt, Pages: 377, Published: 2005
Alison Balter's Mastering Microsoft Access 2000 Development: Access 2000 Development Authors: Alison Balter, Pages: 1342, Published: 1999
Beginning Ajax with ASP.NET Authors: Wallace B. McClure, Scott Cate, Paul Glavich, Craig Shoemaker, Pages: 403, Published: 2006
Visual Basic .NET Developer's Guide to ASP.NET, XML, and ADO.NET Authors: Jeffrey P. McManus, Chris Kinsman, Pages: 592, Published: 2002
Mastering Microsoft Office 2003 for Business Professionals Authors: Gini Courter, Annette Marquis, Pages: 695, Published: 2004

Web:
how to change usercontrol's background? : The Official Microsoft ... I was trying to change usercontrol's background to as same color as the ... in the Silverlight Control tag in your html or aspx page: ...
How to Change Text Size or Colors Dec 18, 2008 ... Page Contents. To Change Text Size; For a Plain Layout View ... The WAI Web site is designed to let you change the text size, text and background colors, ... However, some browsers do not provide as much user control, ...
Changing Page Background Color Talk about Changing Page Background Color. ... control. they programmatically set the color from code-behind. ... User Control Panel, Private Messages, Subscriptions, Search Forums, Forums Home, General Discussion ...
Changing page background with css & javascript - Web Hosting Talk ... Changing page background with css & javascript Web design ... and onmouseout to control what happens on mouse over of the element, and on mouse out of the element. ... User Control Panel, Private Messages, Subscriptions ...
Changing a HTML page's background color via Flash Topics Coverred: How to change the background color of an html page from an ... We can control our Flash movie from a script and we can call a script ... When the user will press the button, the background color of the web page will ...
changing background images depending which page the user is at ... changing background images depending which page the user is at JavaScript. ... i have 4 links at the top of my page. they all have a background image. these links .... User Control Panel, Private Messages, Subscriptions ...
Change the Page Background Color and or Font Color Freeware ... Control the color of your background using the links on yo ... User Review for Change the Page Background Color and or Font Color ...
Ask Chuck: Background colours of an ASP.NET web form - Program ... I have a UserControl that needs to change it's appearance based upon the background colour of the page it appears on. I guess I can do this two ways: ...
12.6 Changing Page Background Colors and Images Several CSS style properties control aspects of element backgrounds. ... change bkgnd image after user selection or onload function setbgImage( ) { var uri ...
Change page background dynamically with RadioButtonList - ASP.NET ... All I want to do is change the page background image when a user selects an option from a radio button list control. ...

Videos:
Creating a web page in under two minutes on iig.nu iig.nu is a "life networking" system that brings you a drag and drop site builder, groups, events calendar and picture/video sharing in a secure ...
"homemade gift ideas for boyfriend""homemade gift ideas for ... CLICK HERE!!!!! = http://rover.ebay.com/rover/1/711-53200-19255-0/1?type=4&campid=5335877794&toolid=10001&customid=&mpre=http%3A%2F%2Fsearch.ebay ...
Windows XP Tweak - Clearing services for better performance This will make your PC's performance a little better by clearing unused services you do not need. Go to start - Control panel Administrative ...
Developing JavaScript with Chickenfoot Google TechTalks July 25, 2006 Rob Miller Michael Bolin ABSTRACT Chickenfoot is a Firefox extension that embeds a JavaScript programming ...
Cisco Enterprise TV Video Data Sheet Cisco Enterprise TV is an interactive application that enables organizations to deliver on-demand video and broadcast live TV channels over an IP ...
Fight Club-drawn on ms paint Every one please show ur mates and leave comments, i want some advice, critisism, jst tell me wut u thot this is an amazing video fo me drawing ...
A New Way to look at Networking Google Tech Talks August 30, 2006 Van Jacobson is a Research Fellow at PARC. Prior to that he was Chief Scientist and co-founder of Packet ...
YouTube Player APIs and Tools Tutorial Stephanie Liu gives a short tutorial on the basic functionality available in the JavaScript and Flash player APIs, as well as the Chromeless ...
Computers versus Common Sense Google TechTalks May 30, 2006 Douglas Lenat Dr. Douglas Lenat is the President and CEO of Cycorp. Since 1984, he and his team have been ...
django: Web Development for Perfectionists with Deadlines Google TechTalks April 26, 2006 Jacob Kaplan-Moss ABSTRACT Django is one of the premier web frameworks for Python, and is often compared ...




Search This Site:










give each user their own page

how to lock the ddl...

confirmation on button click

how achieve history.back() effect in the asp.net code itself ?

y email send 2 mails?

image coloring in asp.net

menu tabs

requiredfieldvalidator & modalpopupextender

readonly vs enabled

dynamically generating menu

regex for no letters

update problem

server values doesn't recognize in firefox through javascript

create excel with headers/footers

what event for dropdownlist

[problem] event delegates

time-out question - webclient versus aspx

dynamic form validation

data binding not working:

shrinking a picture while uploading in aspimage

clear textbox text

cross-page posting by pressing enter

looping through a form

set postion on page after refresh

fun working with colors

problem raeding fileupload.postedfile in to arraybytes

how do you execute a windows application from asp.net?

what is the "vs_targetschema" tag for???

help!!! unable to change width of columns and/or turn off text-wrapping in a gridview!

working with excel in asp.net

  Privacy | Contact Us
All Times Are GMT