Tuesday, June 30, 2009

Using ASP.NET Cookies in Javascript and visa-versa

Is any of you creating a module that requires setting cookies and getting it back using javascript? If you want to do so, then you can be in trouble like me! I was trying to set cookies from asp.net code and trying to read the cookie in javascript code, :) bad part of this experience was, I was not able to read the cookies set by asp.net side code.

Then I started googling the proble. I come across several fundamentals, theories and the way asp.net handles the cookies machanism. Finally eggheadcafe has an answer to my problem. Though it was not a straigh forward answer, I got many hints there to solve my problem.

You must be thinking cookie is a vary simple fundamental thing and its nothing to learn about, but believe me, you will find this article informative.

Friday, June 26, 2009

DotNetNuke - Alternative for using getTabByName or getTab

Hey.
many time in dotnetnuke module development, you need to redirect an existing request to another page. I see most of the users use TabController.getTabByName method to get TabInfo object, And then use its TabId property to navigate to that page using DotNetNuke.Common.Globals.NavigateUrl() method.

Getting entire TabInfo object from database for only getting TabId doesn't seems correct in terms of performance. I see many developers who add intelligence to this by adding entire set of tabs for a portal in HashTable and uses TabId as key and TabName as value. We can add some static methods to get the TabId by name or get TabName by Id.

This approach seems to be perfect, but it still needs memory, if we store it in session state. We always have alternative to store the HashTable into Cache also. That will be more proper way to store data. Adding more tricky work is to add SqlCacheDependency into that. So that when set of Tabs changes, it automatically loads the new set of Tabs.

But this is way too intelligent technique. When you don't need the TabIds too many time in your development or you need to redirect to a specific Tab many times, you should use SiteUrl.config. Let's discuss when its useful.

For example you have a module that shows a message about an offer's page in your site, and you are showing the module in many pages. Now when a user clicks on it, we are sure that we need to redirect user to TabId=100. But you cannot place it hard code, Because you are not sure if the page is having a same id on when it will be deployed.

So the simple work around is to create an entry in the siteUrl.Config file for that TabId. Let's say we create an entry which looks for Offers.aspx and redirect it to Default.aspx?tabid=100. And that's it. It will never go to database to find TabId of the offer.aspx. and the code will get rid of the TabInfo loading from database of maintaining the set of tabs in memory for faster access.

I hope I understand the problem well and make you able to give a right trick. Tell me what you think about it?

Friday, June 19, 2009

DotNetNuke skin objects

DotNetNuke skin objects are ascx control (generally found at ~/Admin/Skins folder) . Skin objects are meant to be reusable UI elements that helps showing a single repeating elements of the page.

For instance, If are running a portal of dotnetnuke and want to show up a latest announcement entry in all your parent and child portal users, you can create a skin object that shows that entry and place that skin object to the skin.This way you can simply integrate the display of the latest announcement for all users in smart way using skin objects.

I worked on several skin objects. here is a quick list:

skin object to display custom logo image selected by an individual portal admin. They can upload the image and the change reflects to the entire portal pages
Vertical navigation which contains custom set of menu for advertising and control panel
News and blog feed display
And many more
We can also show/hide the skin object dynamically. For instance, if you like to hide the skin object when there is no announcement for last 2days, its easily possible to do in it.

Skin object offers smart way to reuse your design components.
There are existing skin objects available with dotnetnuke which provides you some interesting features that you can easily integrate and reuse. Skin objects like logo, user, login, breadcrumb, dnnmenu are almost useful in all the dnn sites. Eagleworx shows a complete list of skin objects and the properties provided by them. You can download the latest skin object documentation from download section of dotnetnuke.

Popular Posts