Home All Groups Group Topic Archive Search About

TabStrip - create tabs dynamicly on client-side

Author
23 Feb 2006 9:10 AM
Daniel Granatshtein
I have created Tab and PaveView on the client side, but i am having a
problem getting the new tab on the server-side.
I understand I can use the viewstate and events but I have no clue how
to do it.
If someone can send me an example on how it's done it would be a great
help.

I add the script for creating the Tab and the PageView (I also made a
small modification to the TabStrip.HTC so I can Name the tab):

function createPageView()
{
    var multiPage = document.getElementById( "MultiPage1" );
    if( multiPage )
    {
         var pageView = multiPage.createPageAt( multiPage.numPages );
        if( pageView )
       {
             pageView.ID = "page" + multiPage.numPages;
            var link = document.createElement("DIV"); link.innerHTML =
"TabName";     
            pageView.appendChild( link );
            creaetTab( pageView.ID );
        }
    }
}

function creaetTab( pageID )
{
        var tabStrip = document.getElementById( "TabStrip1" );
        if( tabStrip )
        {
                var newTab = tabStrip.createTabAt( tabStrip.numTabs ,
"New Client Tab" );
                if( newTab )
                {
                    newTab.ID = "tab" + tabStrip.numTabs;
                    newTab.targetId = pageID; alert( newTab.ID );
                 }
        }
}


The change in the HTC is:
function f_PublicCreateTabAt( index , name )
{
        return f_AddItemAt(index, "tab" , name );
}

function f_AddItemAt(index, type , name )
{
....
    var link = element.document.createElement("A");
    link.innerHTML = name;
    cell.appendChild(link);
....
}


*** Sent via Developersdex http://www.developersdex.com ***

Author
24 Feb 2006 5:30 AM
Steven Cheng[MSFT]
Hi Daniel,

Welcome to the ASP.NET newsgroup.

As for the IE webcontrol, their client side API just create the
corresponding client-side html or HTC elements, so it dosn't change the
webcontrol's Viewstate (which will be used to restore the control's
server-side control hierarchy).  And the ViewState is internally encoded
and serialized into page's html input hidden fields so that we can not
manually edit it.  Therefore, for your scenario, if you need to make your
changes on the IE webcontrol at clientside be persisted when page post
back, you need to record such change manually in page and read them when
the page is postback. For example,we can use an additional html input
hidden fields to store such change, and when page post back, read the
hidden field and apply those changes to the control by server-side methods.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)