CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 4/14/2008 8:00:57 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 5 Views: 60 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
6 Items, 1 Pages 1 |< << Go >> >|
vkkevin
Asp.Net User
Apply Theme with VB codefile.4/14/2008 8:00:57 AM

0/0

I'm trying to add a theme to my masterpage (so its applied to all my content pages) programmatically. So far i have my master page with this:

<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>

...And my "MasterPage.master.vb" code looks like this:
 

1    Partial Class MasterPage
2 Inherits System.Web.UI.MasterPage
3 4 Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
5 Page.Theme = CType(Session("default_theme"), String)
6 End Sub
7 End Class

 
 I run one of my content pages (which are build from my masterpage) and it comes up with this "Exception Details: System.InvalidOperationException: The 'Theme' property can only be set in or before the 'Page_PreInit' event."

 

This may sound like a dumb question but why is this not working? 


 
"ONE MASTERPAGE TO RULE THEM ALL"
mbanavige
Asp.Net User
Re: Apply Theme with VB codefile.4/14/2008 8:22:45 AM

0/0

Although you named your method Page_PreInit, you have set it up to handle the Load event. Load occurs after PreInit.

You need to set the Theme property in the Pages PreInit event.


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.
thirumaran007
Asp.Net User
Re: Apply Theme with VB codefile.4/14/2008 8:27:16 AM

0/0

Hi Friend
User profile to do this
Kindly review the code?

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Profile.UserName = TextBox1.Text
        Profile.MyThemes = DropDownList1.SelectedValue
        Response.Redirect("ProfileTheme.aspx")
    End Sub


 


With Friendly,
Thirumaran

Please remember to click "Mark as Answer" on this post if it helped you
vkkevin
Asp.Net User
Re: Apply Theme with VB codefile.4/14/2008 8:45:28 AM

0/0

mbanavige:
You need to set the Theme property in the Pages PreInit event.
 

 Thanks Mbanavige for that. The debugging did say something about "You need to set the Theme property in the Pages PreInit event.

 So i would change this:

1    Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
to this ?:
1    Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As EventArgs) Handles Me.PreInit
 But then i get errors BC30590: Event 'PreInit' cannot be found ?

 

 


"ONE MASTERPAGE TO RULE THEM ALL"
Dave Sussman
Asp.Net User
Re: Apply Theme with VB codefile.4/14/2008 8:49:19 AM

0/0

The master page doesn't have a PreInit event, so you have to do this either in each page, or elsewhere. I use global.asax to hook up events so that setting the theme happens for all pages. See http://blogs.ipona.com/davids/archive/2008/03/30/8482.aspx for more details.

vkkevin
Asp.Net User
Re: Apply Theme with VB codefile.4/14/2008 9:11:09 AM

0/0

Thank you very much. Problem solved.

"ONE MASTERPAGE TO RULE THEM ALL"
6 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Beginning ASP.NET 3.5: In C# and VB Authors: Imar Spaanjaars, Pages: 734, Published: 2008
Visual Basic Game Programming with DirectX Authors: Jonathan S. Harbour, Pages: 900, Published: 2002
Programming Visual Basic 2005 Authors: Jesse Liberty, Pages: 548, Published: 2005
Pro VB 2008 and the .NET 3.5 Platform Authors: Andrew Troelsen, Pages: 1377, Published: 2008
Beginning Visual Basic 2005 Authors: Thearon Willis, Bryan Newsome, Pages: 799, Published: 2006
Beginning Visual Web Developer 2005 Express: From Novice to Professional Authors: Paul Sarknas, Pages: 334, Published: 2005
ASP.NET 2.0 Cookbook Authors: Michael A. Kittel, Geoffrey T. Leblond, Pages: 989, Published: 2005
Pro ASP.NET 2.0 in VB 2005: From Professional to Expert Authors: Laurence Moroney, Matthew MacDonald, Pages: 1253, Published: 2006
Expert VB 2005 Business Objects Authors: Rockford Lhotka, Pages: 670, Published: 2006
Learning ASP.NET 3.5 Authors: Jesse Liberty, Dan Hurwitz, Brian MacDonald, Pages: 576, Published: 2008

Web:
Apply Theme with VB codefile. - ASP.NET Forums Re: Apply Theme with VB codefile. 04-14-2008, 4:22 AM. Contact. Answer ... Re: Apply Theme with VB codefile. 04-14-2008, 4:27 AM. Contact ...
Master Pages, Themes, and Skins <%@ Master Language="VB" CodeFile="Site.master.vb" Inherits="Site" %> .... Regardless of whether you would like to apply a theme at the page or application ...
Dynamically Selecting Theme or Master Page Mar 30, 2008 ... Apply Theme with VB codefile. Left by The3Factory at 4/14/2008 10:13 AM. Comments have been closed on this topic. ...
Creating Web Site With Asp.Net 2.0 Part 2 As a developer you can apply themes at the application, page, or control level. ... CodeFile="ThemeDemo.aspx.vb" Inherits="ThemeDemo" Theme="SmokeAndGlass"% ...
Module 11 -Themes Apply a Theme to a Web Page. This example applies a Theme to a page at design time. <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Order.aspx.vb" ...
Creating Web Sites with ASP.NET 2.0 <%@ Master Language="VB" CodeFile="CoDeASPNET20.master.vb" .... I've discussed how you can apply theme settings in the web.config file for site-wide ...
vbAccelerator - Contents of code file ... vbAccelerator - Contents of code file: ButtonListBar_ButtonListBarTest_ButtonListBar.vb. Namespace vbAccelerator. Controls.ListBar #Region " Event Argument ...
ng.asp-net-forum.master_pages_themes_and_navigation_controls - fix ... Apply Theme with VB codefile. 5, 23, 4/14/2008 9:11:09 AM. Change master page controls from content page, 0, 26, 4/14/2008 9:08:32 AM ...
Master Pages and Themes <%@ Master Language="VB" CodeFile="SiteTemplate.master.vb" ..... To apply the theme in a web page, you need to set the Theme attribute of the Page ...
Theme="BasicBlue" where is it? - .NET ASP <%@ Page Language="VB" Theme="BasicBlue" AutoEventWireup="false" CodeFile="x. aspx.vb" Inherits="_Replicator" ValidateRequest="false" ...




Search This Site:










site location in vs2005

dnn skinning issue

dnn1.0.10e login fails when new (_blank) window is opened in child portal

database problem

the type initializer for 'bll.customer' threw an exception.

user locked

stored procedures converted to inline sql

enterprise library entlib june 2005 for framenwork 1.1 in vb

signin.ascx : impossibility to loggin

ssl and the lock icon

cookie share between c# and vb.net

createuserwizard causes double postback

oo programming is evil with related to db

i keep getting an error when i try to search on 'pane skins'

how 2 insert a picture to a word automation object ?

how to test the performance of my website ?

using process.start

calling a js function before submitting update form

installing dnn 4.0 with sql server

control keep state

set up requirements

how to add controls to a control collection?

how to override the maintainscrollpositiononpostback on ceratain event

multiple days event

photo gallery

string connection

multiple dnn implementations, one database - any problems?

persisting childcontrols at designtime

create/drop/alter view in access database using odbc

where can i download a machine.config file. i have changed mine by mistake and now asp.net will not start

 
All Times Are GMT