November 2006 - Posts - Raj Kaimal

November 2006 - Posts

Using the Wizard control as a sidebar navigator

You can easily transform the Wizard control as a sidebar navigator by simply hiding the navigation buttons at the bottom as shown below.

wizard_profile

To do this, add a Wizard control to your page. Under "Wizard Tasks", convert the StartNavigation, StepNavigation and FinishNavigation contents to templates. View the source of the page and make the navigation buttons hidden.

<asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0">

    <StartNavigationTemplate>

        <asp:Button ID="StartNextButton" runat="server" CommandName="MoveNext" Text="Next"

            Visible="false"/>

    </StartNavigationTemplate>

    <StepNavigationTemplate>

        <asp:Button ID="StepPreviousButton" runat="server" CausesValidation="False" CommandName="MovePrevious"

            Text="Previous" Visible="false"/>

        <asp:Button ID="StepNextButton" runat="server" CommandName="MoveNext" Text="Next"

            Visible="false"/>

    </StepNavigationTemplate>

    <WizardSteps>

        <asp:WizardStep runat="server" Title="Step 1">

        </asp:WizardStep>

        <asp:WizardStep runat="server" Title="Step 2">

        </asp:WizardStep>

    </WizardSteps>

    <FinishNavigationTemplate>

        <asp:Button ID="FinishPreviousButton" runat="server" CausesValidation="False" CommandName="MovePrevious"

            Text="Previous" Visible="False"/>

        <asp:Button ID="FinishButton" runat="server" CommandName="MoveComplete" Text="Finish"

            Visible="false"/>

    </FinishNavigationTemplate>

</asp:Wizard>

You can now start adding controls into each "wizard step".

Make sure validators, if any, are assigned a unique ValidationGroup to prevent them from being fired when you click on wizard step on the sidebar.

Posted by rajbk | 5 comment(s)
Filed under: ,

IE 6/7 - "Unspecified Error" when accessing offsetParent (Javascript)

I have noticed that IE 6/7 throws an "Unspecified Error" exception when it attempts to get the offsetParent property of a DOM object after the DOM tree has been modified. Here is a repro.  Remove the space in java script before viewing the page:

<html>

<head>

    <script type="text/javascript">

        var myInnerContentDiv;

        function DisplayOffsetParent() {

            try {

                alert("offsetParent is " + myInnerContentDiv.offsetParent);

            }

            catch (e) {

                alert(e.description );

            }

        }

        function InjectContent() {

            document.getElementById("myContent").innerHTML =

            'div id: myContent<div id="myInnerContent" style=border: 1px solid #FF0000;>div id: myInnerContent</div>&nbsp;';

        }

        function Init() {

            myInnerContentDiv = document.getElementById("myInnerContent");

        }

        window.onload = Init;

    </script>

</head>

<body>

    1)<a href="java script:DisplayOffsetParent()">Display offsetParent</a><br />

    2)<a href="java script:InjectContent();DisplayOffsetParent()">Inject content and display offsetParent</a>

    <hr/>

    <div id="myContent" style="border: 1px solid #0000FF;">

        div id: myContent

        <div id="myInnerContent" style="border: 1px solid #FF0000;">

            div id: myInnerContent

        </div>

        &nbsp;

    </div>

</body>

</html>


The page has two div tags - "myContent" and "myInnerContent", one nested in the other. When the page loads, we obtain a reference to the object with id "myInnerContent" and store it in a global variable.

The first link calls a function that displays the offsetParent of "myInnerContent” (we see that it is of type object). The second link calls a function that sets the innerHTML of “myContent” with some data and then tries to get the offsetParent property of "myInnerContent”.

If you are running in IE, you should see "Unspecified Error" when you click on the second link. Firefox on the other hand returns null.


You may run into this issue when you need to store a reference to an object – especially when working with AJAX.


To workaround this, you can store the id of the object in a variable rather than a reference to the object. Like so:

        //a property of some object

        var myInnerContentDivId;

        function DisplayOffsetParent() {

            alert("offsetParent is " + document.getElementById(myInnerContentDivId).offsetParent);

        }

        function Init() {

            myInnerContentDivId = "myInnerContent";

        }


Comments anyone?

Mashups : Trusting the man in the middle

Mashups are very popular words these days. Take an example of a very popular mashup – Meebo 1. Meebo allows you, through a web browser, to logon to all of your IM accounts and chat with people.

Browsers, in general, do not allow a script to make network connections to servers other than the one the web page originally came from. To work around this issue, some Ajax applications use a proxy. This proxy sits on the primary server, makes connections to other servers, and returns relevant data to the Ajax application through the primary server 2. This way, cross domain restrictions are by passed. The ASP.net Ajax framework provides a "Web Service Bridge" for this purpose. Some mashup applications might use other methods to bypass this restriction – Flash uses a file called crossdomain.xml which is placed at root level of a server that the flash movie wishes to access.

Consider the case where you are required to transmit your credentials to a Windows Live authentication server through a mashup application. Regardless of the method being used, a user has no way of knowing 3 what the mashup application is doing with their credentials or data and whether it is connecting securely to the authentication server.

As a rule, before I enter my credentials to see sensitive information on a regular web application, I look for a valid domain and valid SSL connection in the browser window.

I can’t, AFAIK, do the same with mashups – I can only trust that the people running the mashup application have followed best practices to ensure that my credentials and information are being securely transferred and that none of it is being misused.

As time progresses, It is also going to be interesting to see how many services actually allow their data to be accessed through third party mashups.


1 I have nothing against Meebo. I am only using it as an example.
2 This might cause a server bottleneck but that is a different topic.
3 Web applications, I think, should have a page where the user can view their security log. They should be able to see what times they signed on/off and what critical activities they performed on the site.

Posted by rajbk | with no comments
Filed under:

IE7 Buttons

I downloaded IE7 yesterday. So far, it looks and works much better than IE 6 (Good job IE team!).

 I have a small gripe about the position of the buttons though. The buttons I use the most are the Forward, Back, Refresh, Stop and Home buttons. I wish these were all grouped together like so:

IE7_buttons

I have looked around in the registry and group policy editor (gpedit.msc) but could not find a way to do this. There is a binary value - ITBar7Layout in the registry under [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Toolbar\WebBrowser] which may have something to do with this.

I am going to stick to the keyboard shortcuts until I get used to the new layout.

 

More Posts