"Invalid argument" when switching tabs in tabControl
"Invalid argument" when switching tabs in tabControl
I have an ajax tab control and 5 tab panels in it. I am using some AsyncFileUpload controls inside updatepanel in all tabs.the AsyncFileUpload control produces this error when switching Tabs in the TabControl. Everything is inside an UpdatePanel.
The Error that is highlighted in the code will be this:
a._innerTB.style.width=a._inputFile.offsetWidth-107+"px";
to resolve this issue i have to switch asyncfileupload visibility to off when switching tab..
visible only those who are in active tab..
ID="TabContainer1" runat="server" ActiveTabIndex="0" Height="497px"
Width="755px" OnClientActiveTabChanged="ActiveTabChanged"
AutoPostBack="true"
do this in page load event
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
'this will be executed only first time any event happen on web page
' Clear user paging/sort
Session("CurrentPage") = 0
Session("SortExpression") = Nothing
GridViewSortDirection = "ASC"
' Set current query
Session("CurrentQuery") = "SELECT * from circulars ORDER BY cdate DESC"
End If
rebindGridView(Session("CurrentQuery"), gvCirculars)
If TabContainer1.ActiveTabIndex = 0 Then
afuFile.Visible = True
afuFile0.Visible = False
txtCno.Text = "tab1 " '+ Str(TabContainer1.ActiveTabIndex)
ElseIf TabContainer1.ActiveTabIndex = 1 Then
afuFile.Visible = False
afuFile0.Visible = True
afuFile1.Visible = False
afuFile2.Visible = False
afuFile3.Visible = False
txtSub0.Text = "tab2 " '+ Str(TabContainer1.ActiveTabIndex)
else ElseIf TabContainer1.ActiveTabIndex = 2 Then
afuFile.Visible = False
afuFile0.Visible = False
afuFile1.Visible = True
afuFile2.Visible = False
afuFile3.Visible = False
End If
End Sub
Solution 2 : (BEST)
similarly ....
same code can be utilize to check that which tab in tabpanel control has been clicked... accordingly you can do anything.... remember that tab panel triggers postback thats why used in pageload ispostback event... this solution will make a page refresh every time u change the tabs. There is one more better and cool solution is using __doPostBack like this
ur tabconatainer is like this
ID="TabContainer1" runat="server" ActiveTabIndex="0" Height="497px"
Width="755px" OnClientActiveTabChanged="ActiveTabChanged"
AutoPostBack="true"
inside the head write this script. it will be called when tab is changed and it will perform postback call to the function defined in .vb page
(script type="text/javascript")
function ActiveTabChanged(sender, e) {
__doPostBack('TabContainer1_ActiveTabChanged', '');
}
(script/)
you may notice that following code was used earlier in pageload event. Now its not required and it works better than earlier code
Protected Sub TabContainer1_ActiveTabChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabContainer1.ActiveTabChanged
If TabContainer1.ActiveTabIndex = 0 Then
afuFile.Visible = True
afuFile0.Visible = False
txtCno.Text = "tab1 " '+ Str(TabContainer1.ActiveTabIndex)
ElseIf TabContainer1.ActiveTabIndex = 1 Then
afuFile.Visible = False
afuFile0.Visible = True
afuFile1.Visible = False
afuFile2.Visible = False
afuFile3.Visible = False
txtSub0.Text = "tab2 " '+ Str(TabContainer1.ActiveTabIndex)
else ElseIf TabContainer1.ActiveTabIndex = 2 Then
afuFile.Visible = False
afuFile0.Visible = False
afuFile1.Visible = True
afuFile2.Visible = False
afuFile3.Visible = False
End If
End Sub
..
vinod k
Comments