Tuesday, January 16, 2007

Accessing Master page variables from user control

Recently , i had a task to generate meta tags depending on the list of items that are shown on each page (Pageflakes Community Gallery). The list is generated using a repeater and it is under a user control. The header tag is in the Master page, inside which i need to generate the meta tags. Within the header tag , i have <%= MetaTag %>, which dumps whatever assigned to it. MetaTag holds the string of meta tags, which is generate from a predefined schema , after doing some content processing.

Now,calling a public method in master page from user control is bit tricky.To call a public variable from a user control , the following line must be copied to the top of user control with appropiate master page location.

<%@ Reference VirtualPath="~/YourPath/youMasterPage.master" %>

This enables to take the reference of the master page codebehind class and access its public variables.

ASP.MysNameSpace_MasterPageClass myMaster = (ASP.MysNameSpace_MasterPageClass)this.Page.Master;

myMaster.MetaTag = GetMetaTag(.....);


This process of accessing public variable though simple, yet very effective way of dynamic inclusion of meta tags, scripts, style tags and even custom title on to the header tag which is under a common master page.

Ping me if you have anything to share with me.

Configuring multiple sites under a common root

When there are several sites under a common root site, For ex, mysite - >mysite/forum - > mysite/blog , where all three are different solutions and each has a separate config file with some common settings. Due to inheritance nature of web.config, the child config gets the attributes of the parent config.

Therefore, if you have the following, both in mysite and mysite/forum without the location tag, then it will surely cause a runtime error ,"Same session cannot be removed twice"

<httpModules>
<remove name="Session"/>
</httpModules>



To solve this, we can use location tag, which is declared right before the system.web tag.

<location path="mysite">
<system.web>
<!-- do things here ->
<system.web>
</location>



By using the location tag, we can ensure that a particular setting will be applied only to mysite, not to mysite/blogs or myiste/forum.

Similarly , we can avoid such scenarios by removing the common blocks in child config, if we dont want to use location tag.

A Reader's Toolbox

Since the advent of affiliate marketing program many companies use to configure multiple sites under common root. It is quite easy for web companies because it provides lot of web space. This option is not available with all hosting providers but you can know this through webhosting reviews. Most of companies are using wireless security for their servers to avoid risks for servers. You should make plans when buying a web name so that you can implement it easily. You can get all information about hosting using phone service. There are many companies that are providing online support for webhosting net.

Tuesday, January 2, 2007

A year of accomplishments in Pageflakes

In Pageflakes we almost work day and night to make great a startup that will work for all type of users, it was kinda busy year for all of us here. Throughout the year Pageflakes has gone through massive development.Plenty of good flakes, community, new look , better and improved RSS reader, are few features that kept us awake.Finally, it has been a great experience for being a part of such a wonderful yet talented team that is called Pageflakes.:-)