Here are some of the javascript resources I found on the net.
Yahoo! User Interface Library - a huge library with many controls and functions, including animation, effects, menus, calendar and so on.
script.aculo.us - has some basic effects that are really nice to use like fading in, fading out, folding, shaking, pulsating and so on.
Smooth Gallery - a great piece of javascript code that is perfect for showing pictures.
Lightbox2 - great for showing photos!
Shadowbox - ideal for photos or galleries, shows even flash and movies.
Carousels for showing large content.
Monday, March 17, 2008
Master Page PreInit Event Work Around
Because master pages are actually user controls, they do not have PerInit event. But this is the only time when you can change the MasterPageFile property. So, what can we do if we have sophisticated hierarchy of master pages and we need to change the master page of some master page within this master page? The only way to do this is to handle PreInit event of the page, find the appropriate master page and change its master page. But if you still want to have the logic which master page should be used runtime within the master page file, here is one solution to do that with reflection. Override page OnPreInit method and write this code:
// simulates PreInit event for Master pages
MasterPage master = Master;
while ( master != null )
{
MethodInfo mi = master.GetType().GetMethod( "PreInit" );
if ( mi != null )
{
mi.Invoke( master, null );
}
master = master.Master;
}
Then, in the .master file which you would like to change its master page runtime, you should define method like this:
<script runat="server" type="text/C#">
public void PreInit()
{
Account acc = LoggedAccount.GetFromSession( Session );
MasterPageFile = string.Format( "~/local/en-US/{0}/Main.master", acc.Group );
}
</script>
// simulates PreInit event for Master pages
MasterPage master = Master;
while ( master != null )
{
MethodInfo mi = master.GetType().GetMethod( "PreInit" );
if ( mi != null )
{
mi.Invoke( master, null );
}
master = master.Master;
}
Then, in the .master file which you would like to change its master page runtime, you should define method like this:
<script runat="server" type="text/C#">
public void PreInit()
{
Account acc = LoggedAccount.GetFromSession( Session );
MasterPageFile = string.Format( "~/local/en-US/{0}/Main.master", acc.Group );
}
</script>
CodeFile vs Codebehind?
I have just migrated one vs2005 web site project to vs2005 web application project and noticed that instead of CodeFile attribute, tha Page/Control directive uses Codebehind and searched to find something more about these two.
CodeBehind
Specifies the name of the compiled file that contains the class associated with the control. This attribute is not used at run time.
Note:
This attribute is included for compatibility with previous versions of ASP.NET, to implement the code-behind feature. In ASP.NET version 2.0, you should instead use the CodeFile attribute to specify the name of the source file, along with the Inherits attribute to specify the fully qualified name of the class.
CodeFile
Specifies a path to the referenced code-behind file for the control. This attribute is used together with the Inherits attribute to associate a code-behind source file with a user control. The attribute is valid only for compiled controls.
CodeBehind
Specifies the name of the compiled file that contains the class associated with the control. This attribute is not used at run time.
Note:
This attribute is included for compatibility with previous versions of ASP.NET, to implement the code-behind feature. In ASP.NET version 2.0, you should instead use the CodeFile attribute to specify the name of the source file, along with the Inherits attribute to specify the fully qualified name of the class.
CodeFile
Specifies a path to the referenced code-behind file for the control. This attribute is used together with the Inherits attribute to associate a code-behind source file with a user control. The attribute is valid only for compiled controls.
Subscribe to:
Posts (Atom)
