Showing posts with label loaded. Show all posts
Showing posts with label loaded. Show all posts

Wednesday, March 28, 2012

Tab Container Error after a Refresh

I have a tab container with two tab panels inside of it, and they work perfectly well the first time the page is loaded. If I hit refresh (not post back I am talking F5 or the browser refresh button) the page loads up except for the tab container which does not show up.

The error I receive in IE is the following

Line: 6
Char 31345
Error: Object Expected

When I run this in Firefox and check the error in FireBug It tells me the following error occurred

h is not a constructor

createCallback(undefined,Object,null,Object,div#ctl00_mainContent1_ComparisonPieCharts1_TabContainer1_PublisherTab)ScriptResource.ax... (line 5)

(no name)()default.aspx (line 988)

createCallback(Object _disposableObjects=[2] _components=Object,Object)ScriptResource.ax... (line 5)

createCallback()ScriptResource.ax... (line 5)

createCallback()ScriptResource.ax... (line 5)

Function.__typeName="Function";Function.__class=true;Function.createCallback=fun...

Thanks in advance for your help,

Brendan

I set my ScriptMode for my scriptmanager to Debug and now I found that the error message is really

Sys.ArgumentUndefinedException: Value cannot be undefined.Parameter name: type

Sys$CultureInfo$_getAbbrMonthIndex("")ScriptResource.ax... (line 5762)

{name: "element", mayBeNull: true, domElement: true, optional: true}


Hi Brendan,

Can you post a simple repro of your issue?

Tab Content Disappears by Clicking on Active Tab

I am puzzled as to why the dynamically loaded content of an Active Tab disappears when I click on the Active Tab. But if I click on another Tab and go back to the previous tab the content appears.

<%@dotnet.itags.org.PageLanguage="C#"MasterPageFile="~/MasterPages/DeafaultMasterPage.master"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"Title="Default Page" %>
<asp:ContentID="Content2"ContentPlaceHolderID="cphBody"Runat="Server">
<scripttype="text/javascript"language="javascript">
function ActiveTabChanged(sender, e)
{
__doPostBack('<%= tcDefault.ClientID %>', sender.get_activeTab().get_headerText());
}
</script>
<ajaxToolkit:TabContainerID="tcDefault"runat="server"OnClientActiveTabChanged="ActiveTabChanged"

OnActiveTabChanged="ActiveTabChangedServer">

<ajaxToolkit:TabPanelID="tab1"runat="server"HeaderText="Info"EnableViewState="true">

<ContentTemplate>Dynamic content, load UserControl

</ContentTemplate>

</ajaxToolkit:TabPanel>

<ajaxToolkit:TabPanelID="tab2"runat="server"HeaderText="tab 2"EnableViewState="true"/></ajaxToolkit:TabContainer>

Code Behind

protected void Page_Load(object sender, EventArgs e) { ScriptManager sm = ScriptManager.GetCurrent(this.Page); sm.RegisterAsyncPostBackControl(tcDefault); }  
protected void ActiveTabChangedServer(object sender, EventArgs e) {// Initialize Tab TabContainer tc = (TabContainer)CommonUtility.FindControlRecursive(this,"tcDefault");if (tcDefault.ActiveTab == tab1) { LoadControl1(tc); }if (tcDefault.ActiveTab == tab2) {//Do something in code LoadControl2(tc); } }

I noticed if I did the following;

protected void Page_Load(object sender, EventArgs e) { ReCreateTab(); }

The content in the tab sticks, but then the content is displayed twice. I know it has something to do with the ViewState, but not sure how to debug and what to read, I am new at this .Net and Ajax.

Any help would be appreciate.


Hi,

This is a FAQ regarding dynamic controls in asp.net. Please refer to this:

1. Why do I have to recreate dynamic controls every time? /Why dynamic controls are disappeared on PostBack?

Whenever a request comes, a new instance of the page that isbeing requested is created to serve the request even it's a PostBack. Allcontrols on the page are reinitialized, and there state can be restored fromthe ViewState in a later phase.

The dynamic controls have to be recreated again and added tothe control hierarchy. Otherwise, they won't exist in the page.

Please be careful with when to create dynamic controls. Inorder to keep their state, they have to be created before the LoadViewStatephase. Page_Init as well as Page_Load methods are options available.

For more information about this topic, please refer to thisarticle:

Creating Dynamic Data Entry User Interfaces[http://msdn2.microsoft.com/en-us/library/aa479330.aspx ]

Hope this helps.

Saturday, March 24, 2012

TabContainer - Two Components with the same id error

Hi. I've loaded the most recent AJAX Controls Toolkit and am using a TabContainer and TabPanels. I try to run a report from Oracle by clicking on an image button elsewhere on the screen, which should (and does) cause the report to be generated. It then is to switch TabPanels and show the report. At that point, I get:

Microsoft JScript runtime error: Sys.InvalidOperationException: Two components with the same id 'TabContainer1_TabPanel1' can't be added to the application.

I've researched on the forums and found a few proposed fixes to this issue. Unfortunately, none of them seem to work. Has anyone seen this with the TabContainer, and is there a fix? If I set debug=false in the web.config it goes away, but I realize that isn't truly a solution.

Regards,

Mark

Hi Mark,

I am having similar problem. My case was, I have a user control that contains MultipleSelectorExtender from ajax control toolkit. On my page, I need to hide and show this user control on a specific event. The first time I set the Visible property of this user control that contains the MultipleSelectorExtender, I am not getting any error. The next time that I attempted to set the visible property of the usercontrol to true, I got the error message "Sys.InvalidOperationException: Two componnents with same id '<multipleselectorextender's Id>' can't be added to the application."

It seems that the component was recreated again when the container wast set to visible.

Have you found solution to your problem? If so, kindly post it here.

tia,

/randz