Thursday, April 21, 2005
by Nik Kalyani
Thursday, April 21, 2005 9:33:00 AM (Pacific Standard Time, UTC-08:00)

Just got word from ComponentArt that I am going to be a member of their MVP Program. Quite excited about collaborating with other developers to create cool ComponentArt-based solutions for DotNetNuke.

 

 Wednesday, April 20, 2005
by Nik Kalyani
Wednesday, April 20, 2005 7:31:38 PM (Pacific Standard Time, UTC-08:00)

There are many different solutions for creating tabbed content in HTML pages. For a number of my apps, I needed a simple, lightweight solution that was easy to use and to integrate with my apps. I came up with a simple solution and am sharing it here. Hopefully someone will find it useful.

The solution consists of a table containing the tabs and DIV’s representing the content for each tab. The tabs table has one cell for each tab with ID of “Tab_n” where n starts with 0 and increases by 1 for each tab. Add an onClick handler for each cell that calls tabClickHandler(n). Finally, create a DIV for each tab’s content and set its ID to be “Panel_n” where n starts with 0 and increases by 1 for each tab. Add a style attribute of “display: none” for all DIVs representing the tab content except for the first, which should be set to “display:block”.

<script language="javascript">
function tabClickHandler(tab)
  {
    i = -1;
    while (true)
    {
        i++;
        objTab = eval(document.getElementById("Tab_" + i));

        if (objTab)
        {
            objTab.className = (i == tab) ? "Speerio-SelectedTab" : ((i > tab) 
                                          ?
"Speerio-RightTab" : "Speerio-LeftTab");
            document.getElementById("Panel_" + i).style.display = (i == tab ? "block" : "none");
        }
        else break;
     }
  }
</script>

<style>
    .Speerio-Tabs { width:100%; color: black; font-family: Verdana,Arial,Helvetica,Sans Serif}
    .Speerio-TabLeftSpacer {width:10%;  BORDER-BOTTOM: 1px solid black}
    .Speerio-TabRightSpacer {width:10%; BORDER-BOTTOM: 1px solid black}
    .Speerio-SelectedTab { width:20%; BORDER-RIGHT: 1px solid black; BORDER-TOP: 1px solid black; BORDER-LEFT: 1px solid black}
    .Speerio-LeftTab {cursor: hand; width:20%;  BORDER-TOP: 1px solid #cccccc; BORDER-LEFT: 1px solid #cccccc; CURSOR: hand; BORDER-BOTTOM: 1px solid black; background-color: #eeeeee}
    .Speerio-RightTab {cursor: hand; width:20%;  BORDER-RIGHT: 1px solid #cccccc; BORDER-TOP: 1px solid #cccccc; BORDER-LEFT: medium none; CURSOR: hand; BORDER-BOTTOM: 1px solid black; background-color: #eeeeee}
    .Speerio-TabLabel { font-size: 8pt; font-weight: bold; color: black; font-family: Verdana,Arial,Helvetica,Sans Serif}
</style>

<table cellspacing="0" cellpadding="2" border="0" align="center" class="Speerio-Tabs">
 <tr>
  <td class="Speerio-TabLeftSpacer">&nbsp;</td>
  <td id="Tab_0" class="Speerio-SelectedTab" nowrap align="Center" valign="Middle" onClick="tabClickHandler(0)">
   <span class="Speerio-TabLabel">ABC</span></td>
  <td id="Tab_1" class="Speerio-RightTab" nowrap align="Center" valign="Middle" onClick="tabClickHandler(1)">
   <span class="Speerio-TabLabel">DEF</span></td>
  <td id="Tab_2" class="Speerio-RightTab" nowrap align="Center" valign="Middle" onClick="tabClickHandler(2)">
   <span class="Speerio-TabLabel">GHI</span></td>
  <td id="Tab_3" class="Speerio-RightTab" nowrap align="Center" valign="Middle" onClick="tabClickHandler(3)">
   <span class="Speerio-TabLabel">JKL</span></td>

  <!-- Add as many additional cells corresponding to tabs here -->
  <td class="Speerio-TabRightSpacer" align="right">&nbsp;</td>
 </tr>
</table>
  <!-– Add a DIV for each tab’s content here -->

<div id="Panel_0" style="display:block" width="100%">Contents of the first tab</div>
<div id="Panel_1" style="display:none" width="100%">
Contents of the second tab
</div>
<div id="Panel_2" style="display:none" width="100%">
Contents of the third tab
</div>
<div id="Panel_3" style="display:none" width="100%">
Contents of the fourth tab</div>


 

 

by Nik Kalyani
Wednesday, April 20, 2005 8:46:40 AM (Pacific Standard Time, UTC-08:00)

The Secrets of Strong Naming by Mike Gunderloy -- If you've been working with .NET for any length of time, you've probably run across the concept of a strong name. No, that doesn't mean that your assemblies should have names like MyCompany.Gorilla.Biceps. The strength of a strong name lies in the protection that it offers your assemblies. The .NET Framework uses strong names to identify assemblies and to protect them from tampering. In this article, Mike Gunderloy shows you how strong names are constructed and demonstrates the mechanics of working with strong names in .NET.

 

 Tuesday, April 19, 2005
by Nik Kalyani
Tuesday, April 19, 2005 4:07:50 PM (Pacific Standard Time, UTC-08:00)

Navin Pathuru asks:

Currently we have a requirement where our client wants us to do something about loading Dnn in Netscape 4.x version. We know Dnn uses a lot of client side javascript so there are going to be problems with this. But we just
want to do our best. The approach we want to take is to figure out the browser version and load a different
skin one which has really minimal graphics when we detect it is Netscape 4.x. I am wondering if you will
be able to write your thoughts about this approach in your blog.

Nik’s response:

Navin, this is a great question. Before I answer it, I do want to point out that most of the client-side Javascript you see on a DNN page is emitted by ASP.Net, the menu and other modules. DNN itself does not generate a lot of client-side script, especially if you disable the Client API.

Now, to answer your question. Since we have the DNN source code, the dime answer is change the core to suit your needs. But this is neither fun nor practical. Let’s go on to the dollar answer.

DNN uses the tab settings (inherited or set directly) to determine which skin is to be displayed. You can override this with querystring parameters to force a certain skin to be displayed. Also, due to its IBuySpy legacy, DNN has the rather unfortunate artifact called the Admin skin which forces a skin switcheroo whenever a non-View module control is displayed. (I think this will go away as part of DNN’s continued evolution.)

So, if there is no way to dynamically switch the skin, how is this problem to be solved. After noodling about this for a minute, it occurred to me. Although DNN allows skins to be intelligent, most skins are dumb, i.e. they intersperse some DNN controls, HTML, images and CSS to render a page layout. Most skins do not take advantage of their ability to do anything ASP.Net allows by virtue of their being usercontrols. This is precisely what we can do to solve the problem at hand.

The solution consists of a single file that I’ll call a “Skin Proxy.” The Skin Proxy can be used to dynamically select a skin based upon any user, portal, tab or browser properties. In my example, I have used a browser property since that was the focus of Navin’s question. Basically, the Skin Proxy creates a string based on some browser properties and then attempts to load a control (i.e. a skin) with a name matching the string.

SkinProxy.ascx

<%@ Control language="c#" %>
<script runat="server">
 protected void Page_Load(object s, EventArgs e)
 {
     string browser = Request.Browser.Browser.ToLower();
     string version = Request.Browser.MajorVersion.ToString();

     if (Request.QueryString["debug"] != null)
         Response.Write(browser + version + ".ascx");
     else
        {
             try
             {
                 this.Controls.Add(this.LoadControl(browser + version + ".ascx"));
             }
             catch
             {
                 this.Controls.Add(this.LoadControl("Default.ascx")); 
             }
        }
 }
</script>

In this code, the first couple of lines get the browser and browser major version into string variables. Then, an attempt is made to load a control whose name corresponds to the concatenated browser and version. If this is unsuccessful, a control named “Default.ascx” is loaded. (If you add a querystring variable named “debug” the script reports the name of the control that would be loaded instead of actually loading it. This is helpful for figuring out what to name your control.)

I tested this out with IE and Firefox and everything seemed to work OK. Please do post here if you find problems with the script.

 

 Monday, April 18, 2005
by Nik Kalyani
Monday, April 18, 2005 3:50:26 PM (Pacific Standard Time, UTC-08:00)

I don’t think I will be using Yahoo maps again. Nothing against Yahoo. It’s just that Google maps are so much cooler. There’s nothing like seeing a satellite map of your intended travel route and close-ups of each turn along the way.

Just for fun I mapped the walk from my place to the White House. Be sure to click on the numbers next to each turn instruction.

#    Comments [0] - Trackback    

RSS feed
Search and Links
Bling

View Nik Kalyani's profile on LinkedIn

Contact me: nik*kalyani.com (replace "*")

TechBubble
www.flickr.com
This is a Flickr badge showing public photos from techbubble. Make your own badge here.
Statistics
Total Posts: 204
This Year: 22
This Month: 0
This Week: 0
Comments: 231
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008
Nik Kalyani
Sign In
All Content © 2008, Nik Kalyani