[CLOSED] Error in tabpanel and ajaxevent?

  1. #1

    [CLOSED] Error in tabpanel and ajaxevent?



    Hi,
    Se the example code. It fails if tab2 has not been clicked on before the button is pressed. I need to fill a tab that has not been clicked on. How can I solve that?


    
    
    public partial class Test_Default : System.Web.UI.Page
    
    
    {
    
    
    protected void Page_Load(object sender, EventArgs e)
    
    
    {
    
    
     
    
    
    }
    
    
    protected void btn_Click(object sender, EventArgs e)
    
    
    {
    
    
    Tab2.Html = "TEST";
    
    
     
    
    
    }
    
    
    }
    
    
     
    
    
     
    
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    
    
    <head>
    
    
    <title>Test</title>
    
    
    </head>
    
    
    <body>
    
    
    <form id="Form1" runat="server">
    
    
    <ext:ScriptManager ID="ScriptManager1" runat="server" />
    
    
     
    
    
    <ext:TabPanel ID="TabPanel1" runat="server" ActiveTabIndex="0" Height="300">
    
    
    <Tabs>
    
    
    <ext:Tab ID="Tab1" runat="server" Title="Tab 1">
    
    
    <Content>
    
    
    </Content>
    
    
    </ext:Tab>
    
    
    <ext:Tab ID="Tab2" runat="server" Title="Tab 2">
    
    
    <Content>
    
    
    </Content>
    
    
    </ext:Tab>
    
    
    <ext:Tab ID="Tab3" runat="server" Title="Tab 3">
    
    
    <Content>
    
    
    </Content>
    
    
    </ext:Tab>
    
    
    </Tabs>
    
    
    </ext:TabPanel>
    
    
    
    
    
    <ext:Button ID="Button1" runat="server" Text="Submit">
    
    
    <AjaxEvents><Click OnEvent="btn_Click"></Click>
    
    
    
    
    
    </AjaxEvents>
    
    
    </ext:Button>
    
    
    
    
    
    
    
    
     
    
    
     
    
    
    </form>
    
    
    </body>
    
    
    </html>
    Best regards
    Mikael



  2. #2

    RE: [CLOSED] Error in tabpanel and ajaxevent?



    Hi Mikael,

    I copied your sample into a test page but it threw an exception when I tried to view.

    One quick thing I noticed... if you're using <AjaxEvents>, please ensure the EventArgs on the server-side event handler are "AjaxEventArgs". I think you might need to change the following code or else the <Click> AjaxEvent will not work.

    Example

    // Old
    protected void btn_Click(object sender, EventArgs e)
    
    // New
    protected void btn_Click(object sender, AjaxEventArgs e)
    Hope this helps.
    Geoffrey McGill
    Founder
  3. #3

    RE: [CLOSED] Error in tabpanel and ajaxevent?



    Hi no that did not solve it. That was just a miss in my test example. Please try this code.
    The problem is really easy to replicate. All you have to do is to insert html to a tab in a ajaxevent, to a tab that has not been clicked on when the ajax button is pressed.

    code behind
    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using NS_TPGlobal;
    using System.Data.SqlClient;
    using Coolite.Ext.Web;
    using System.Xml;
    
    
    
     
    
    
    public partial class Test_Default : System.Web.UI.Page
    {
    
    
    
        protected void btn_Click(object sender, AjaxEventArgs e)
        {
            Tab2.Html = "TEST";
    
    
    
        }
    
    
    }
    aspx
    <%@ Page Language="C#" EnableEventValidation="false" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test_Default" %>
     
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
    
    
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
    <title>Test</title>
    </head>
    
    
    <body>
    <form id="Form1" runat="server">
        <ext:ScriptManager ID="ScriptManager1" runat="server" />
    
    
    
        <ext:TabPanel ID="TabPanel1" runat="server" ActiveTabIndex="0" Height="300">
            <Tabs>
                <ext:Tab ID="Tab1" runat="server" Title="Tab 1">
                    <Content>
                    </Content>
                </ext:Tab>
                <ext:Tab ID="Tab2" runat="server" Title="Tab 2">
                    <Content>
                    </Content>
                </ext:Tab>
                <ext:Tab ID="Tab3" runat="server" Title="Tab 3">
                    <Content>
                    </Content>
                </ext:Tab>
            </Tabs>
        </ext:TabPanel>
    
    
        
        <ext:Button ID="Button1" runat="server" Text="Submit">
        <AjaxEvents><Click OnEvent="btn_Click"></Click>
        
        </AjaxEvents>
        </ext:Button>
    
    
    </form>
    </body>
    </html>
    Best regards
    Mikael
  4. #4

    RE: [CLOSED] Error in tabpanel and ajaxevent?

    Hi Mikael,

    please try to set DeferredRender="false" for TabPanel

  5. #5

    RE: [CLOSED] Error in tabpanel and ajaxevent?



    Hi Mikael,

    By default, the "body" of the Tab is not rendered (created on the DOM) until the Tab becomes the ActiveTab. This is an optimization feature to speed the client-side rendering. Basically, the body/content is not available until it's needed.

    In your sample, when the AjaxEvent returns, it was attempting to update the .Html (body) of the Tab, but the body of the Tab had not yet rendered and a JavaScript error was thrown indicating that the "body" was not available.

    Setting the .DeferredRender property to "false" will instruct the TabPanel to render the content/body of all Tabs immediately upon the initial page load. Currently the default value of .DeferredRender is "true".

    I can see how this client-side "Deferred Rendering" is going to cause problems so I changed the default value of the .DeferredRender property to "false".

    If you do an svn update and rebuild, your original code sample will now work.

    Hope this helps.
    Geoffrey McGill
    Founder
  6. #6

    RE: [CLOSED] Error in tabpanel and ajaxevent?

    Hi guys
    Thanks for the info, I recompiled with the latest version and it worked like a charm! Many thanks!

    Best regards
    Mikael

Similar Threads

  1. [CLOSED] TabPanel load content in AjaxEvent
    By methode in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 01, 2009, 1:26 PM
  2. [CLOSED] Error in AjaxEvent
    By Jurke in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Apr 23, 2009, 1:56 PM
  3. [V0.7] Error with Button and AjaxEvent
    By louis in forum 1.x Help
    Replies: 3
    Last Post: Apr 23, 2009, 6:55 AM
  4. Error using contextMenu and AjaxEvent
    By plykkegaard in forum 1.x Help
    Replies: 4
    Last Post: Mar 14, 2009, 7:44 PM
  5. Error on AjaxEvent Response
    By jcanton in forum 1.x Help
    Replies: 2
    Last Post: Jan 25, 2009, 4:38 PM

Posting Permissions