Results 1 to 5 of 5

Thread: [RESOLVED] Ajax TabContainer problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2006
    Location
    CA, USA
    Posts
    81

    Resolved [RESOLVED] Ajax TabContainer problem

    Hi,

    (this is actually MOSS 2007 question. I don't know where to post it exactly)
    I am developing a webpart with Ajax TabContainer within an UpdatePanel. I developed an web application and tried my code there first everything works fine. Then I added the same to a webpart, deployed it and tested. The tabcontainer displays well. The control is supposed to load data dynamically on tabchange with a postback. But it is not doing so in my sharepoint site where as it works in web application. I am using C# 2.0

    Then I went to view source of both the pages and detected the problem. It is all about the client ID of the tabcontainer. I am registering some script to the page as follows:


    StringBuilder sbScript = new StringBuilder();
    sbScript.Append("<script type=\"text/javascript\">");
    sbScript.Append("function ActiveTabChanged(sender, e) {");
    sbScript.Append("__doPostBack("+tabcontainer.ClientID +", sender.get_activeTab().get_headerText()) }");
    sbScript.Append("</script>");

    System.Web.UI.ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "ScriptToRSSTabChange", sbScript.ToString(), false);


    When I view source:

    the script is registered as:

    sbScript.Append("__doPostBack('tabcontainer', sender.get_activeTab().get_headerText()) }");

    In my web application tabcontainer.ClientID is "tabcontaner" so the script works fine and the control postsback and gets the data. But in my sharepoint site the tabcontainer.ClientID is something like "someGUID_tabcontainer" which is not the same as the one registered in the script. so the tabcontainer is making complete page postback instead of partial postback and therefore looses it's viewstate.

    I tried with tabcontainer.UniqueID and also <%=tabcontainer.ClientID%> in the script. but of no use.

    While using <%=tabcontainer.ClientID%>, if I use '<%=tabcontainer.ClientID%>' the script gets registered as

    sbScript.Append("__doPostBack('<%=tabcontainer.ClientID%>', sender.get_activeTab().get_headerText()) }");

    if I don't give single quote or double quote, the tabcontainer is not getting diplayed at all

    Any suggestions please.....

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Ajax TabContainer problem

    This is why I discourage the use of inline code.

    Your latest attempt is close.
    Code:
    sbScript.Append("__doPostBack('" + tabcontainer.ClientID%> + "', sender.get_activeTab().get_headerText());");

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2006
    Location
    CA, USA
    Posts
    81

    Re: Ajax TabContainer problem

    Thanks for the response. Which attempt do you mean?

    I used this and it worked.

    Code:
    sbScript.Append("__doPostBack('" + this.UniqueID +"_tabcontainer', sender.get_activeTab().get_headerText()) }");

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [RESOLVED] Ajax TabContainer problem

    The last green line in your first post. I tried to amend it but I forgot to remove a %> at the end of the ClientID.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Apr 2006
    Location
    CA, USA
    Posts
    81

    Re: [RESOLVED] Ajax TabContainer problem

    I tried that even. But when I view source, in the javascript function I see it the ID as tabcontainer where as the actual client ID of the control in view source is "someguid_tabcontainer" i think "someguid" is the guid of the sharepoint webpart. that's why I gave this.UniqueID + "_tabcontainer" and it worked...

    I just wonder why tabcontainer.ClientID is not returning the clientID. Problem is resolved yet I am curious to know this. I am including this code in createchildcontrols event of the webpart control and. The control is being added to UpdatePanel and the UpdatePanel to the webpart...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width