 |
BOOK: Beginning ASP.NET 4.5 : in C# and VB
 | This is the forum to discuss the Wrox book Beginning ASP.NET 4.5: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-31180-6 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning ASP.NET 4.5 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|
|

September 1st, 2013, 10:25 AM
|
|
Authorized User
|
|
Join Date: Apr 2009
Posts: 10
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Profile colors - Chapter 17 PERSONALIZING WEBSITES
Chapter 17 PERSONALIZING WEBSITES
I have been able to get saving info in a logged in Profile successfully Thank you. I am trying use the AJAX Color Picker Extender to allow the user to select background and foreground colors for the MasterPage. How do I change colors in the MasterPage from MyProfile.aspx? I want to be able to save those colors in the Profile once I get it to work.
|
|

September 2nd, 2013, 03:58 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
I am not familiar with that control but I assume it has a Value or SelectedColor property or something like that to get at the selected color? If that's the case, you should be able to do something like this:
Profile.SelectedColor = myControl.SelectedColor;
If that doesn't help, can you provide more details about working with this control?
Cheers,
Imar
|
|

September 3rd, 2013, 10:10 AM
|
|
Authorized User
|
|
Join Date: Apr 2009
Posts: 10
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Profile colors - Chapter 17 PERSONALIZING WEBSITES
I can change the textbox colors in MyProfile.aspx. I can't change the colors in all the pages that use the MasterPage. I tried:
Master.FindControl("MasterPage");
MasterAttributes.Add("style", "background-color: ColorTranslator.FromHtml(bgColorString)");
bgColorString is set to the color I selected so I have the correct color value, however I can't change the colors in the pages that use the MasterPage. Any suggestions?
|
|

September 3rd, 2013, 01:55 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
To which control are you trying to apply the background? What control is "MasterPage"?
Imar
|
|

September 3rd, 2013, 05:16 PM
|
|
Authorized User
|
|
Join Date: Apr 2009
Posts: 10
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Profile colors - Chapter 17 PERSONALIZING WEBSITES - in the BOOK: Beginning ASP.NET 4
I was trying to follow your MasterPage in the book. When you what control am I trying to change, I am trying to change the background color for all the pages that use the MasterPage. I am a beginner and I am including my MasterPage. How do I change colors programmatically?
<%@MasterLanguage="C#"AutoEventWireup="true"CodeFile="ISI.master.cs"Inherits="MasterPages_ISI_MasterPage" %>
<%@RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="cc1" %>
<!DOCTYPEhtml>
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
<asp:ContentPlaceHolderID="head"runat="server">
</asp:ContentPlaceHolder>
<linkhref="~/App_Themes/ISI_Theme/ISI_Styles.css"rel="stylesheet"/>
<scriptsrc="/Scripts/modernizr-2.6.2.js"></script>
<styletype="text/css">
.auto-style1 {
width: 599px;
}
</style>
</head>
<body>
<formid="MasterPage"runat="server">
<ajaxToolkit:ToolkitScriptManagerrunat="server"ID="ajaxScriptManager"EnablePartialRendering="true"CombineScripts="false"/>
<divid="PageWrapper">
<header>
<imgsrc="../Images/CompanyLogo.gif"/><imgclass="auto-style1"
src="../Images/CompanyName.gif"/>
<asp:LabelID="lblHello"runat="server"Font-Bold="True"Font-Size="Medium"ForeColor="Goldenrod"Visible="False"></asp:Label>
<asp:LabelID="lblUserName"runat="server"Font-Bold="True"Font-Size="Medium"ForeColor="Goldenrod"></asp:Label>
<asp:LoginStatusID="LoginStatus1"runat="server"/>
<br/><br/>
<asp:SiteMapPathID="SiteMapPath1"runat="server"PathSeparator=" > "
RenderCurrentNodeAsLink="True">
<PathSeparatorStyleFont-Bold="True"/>
</asp:SiteMapPath><br/><br/>
</header>
<aside>
<asp:SiteMapDataSourceID="SiteMapDataSource1"runat="server"
ShowStartingNode="False"/>
<asp:TreeViewID="TreeView1"runat="server"DataSourceID="SiteMapDataSource1"
ShowExpandCollapse="false">
</asp:TreeView>
</aside>
<section>
<asp:ContentPlaceHolderid="CenterPanelPlaceHolder"runat="server">
</asp:ContentPlaceHolder>
</section>
<footer>
<asp:ContentPlaceHolderID="footerPlaceHolder"runat="server">
<asp:LoginNameID="LoginName1"runat="server"FormatString="You are logged in as {0}"/>
<asp:LoginViewID="LoginView1"runat="server">
</asp:LoginView>
</asp:ContentPlaceHolder>
</footer>
</div>
</form>
</body>
</html>
|
|

September 3rd, 2013, 06:26 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
The following works for me:
Code:
var control = Master.FindControl("MasterPage") as HtmlControl;
control.Attributes.Add("style", "background-color:red;");
However, instead of directly setting an inline style, I would add a CSS bock. You could add that block to the <head> section of the master page, and assign a value using an ASP literal:
Code:
<style>
body {
background-color: <asp:Literal runat="server" ID="UserColor"></asp:Literal>
}
</style>
with something like this in the master's code behind:
UserColor.Text = "blue";
EVen better might be to generate a user defined CSS file on the fly but that's a different topic.
Cheers,
Imar
|
|

September 20th, 2013, 09:28 AM
|
|
Authorized User
|
|
Join Date: Apr 2009
Posts: 10
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Chapter 17 PERSONALIZING WEBSITES
It took awhile but I finally got it to work using your suggestion.
Being a rank beginner, what CONTROLs would you use to create a OUTLOOK looking CALENDAR? Being able to select a date from the ASP.NET CALENDAR control and create a days page with appointments for that day. I don't want to buy one because I want to learn how to do things like this.
Thank You.
|
|

September 20th, 2013, 12:23 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
There are no controls that support this out of the box. You could use a ListView and modify the various templates but I doubt that will give you the look and feel you need. You could also build your own control by inheriting WebControl or one of the other base classes. Building controls is quite a large topic so I would recommend getting a dedicated book on that subject.
If you require something like this for a real-world application, I would look into one of the existing (commercial) controls.
Cheers,
Imar
|
|

September 20th, 2013, 12:53 PM
|
|
Authorized User
|
|
Join Date: Apr 2009
Posts: 10
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Thanks. If you can suggest some of the commercial controls, I would appreciate it. Thanks for responding on this.
|
|

September 20th, 2013, 01:30 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
DevExpress has a nice one: http://demos.devexpress.com/ASPxSche...kWeekView.aspx but I am sure other vendors like Telerik or Componet One have a version too.
Imar
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|
 |
|