Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6813617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:35:28+00:00 2026-05-26T20:35:28+00:00

I have a checkbox and a textbox client which works good when they are

  • 0

I have a checkbox and a textbox client which works good when they are not in tabpanel, but when I am putting them in a tabcontainer I am getting this error:

“Object reference not set to an instance of an object.”

That’s happening when the page is trying to execute this JS code:
var chkTotalMiles = document.getElementById(“<%=chkTotalMiles.ClientID %>”);

I have the checkbox in ajax tabpanel, here is the code:

  <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </ajaxToolkit:ToolkitScriptManager>
    <ajaxToolkit:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0">
    <ajaxToolkit:TabPanel ID="TabPanel1" runat="server" HeaderText="Ground Transportation">
    <ContentTemplate>
    <h3>Ground Transportation</h3>
<table>
<tr>
<td><asp:CheckBox Checked="false" ID="chkTotalMiles" runat="server" />&nbsp;&nbsp;Total Miles Driven:&nbsp;</td>
<td><asp:TextBox ID="txtTotalMiles" Enabled="false" runat="server" /></td>
<td><asp:CheckBox Checked="false" ID="chkTotalGasoline" runat="server" />&nbsp;&nbsp;Total Gasoline Fuel Consumption:&nbsp;</td>
<td><asp:TextBox ID="txtTotalGasoline" Enabled="false" runat="server" /></td>
</tr>
</table>
    </ContentTemplate>
 </ajaxToolkit:TabPanel>
    </ajaxToolkit:TabContainer>   

Any idea what am I doing wrong?
Thanks, Laziale

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:35:29+00:00Added an answer on May 26, 2026 at 8:35 pm

    Because you can’t access controls directly in the TabContainer, it sounds like you’ll have to create the client-side code in the code-behind:

    JavaScript

    toggleInputEnabled = function(checkCtrl, txtCtrlID){
        var el = document.getElementById(txtCtrlID);
        if (el){
            el.disabled = !checkCtrl.checked;
        }
    }
    

    Code-behind

    In the code-behind, you need to find the controls in the active tab of the TabContainer, and assign an onclick attribute to the checkbox:

    foreach (TabPanel pnl in tbc.Tabs)
    {
        var chkCtrl = pnl.FindControl("CheckBox1") as CheckBox;
        if (chk != null)
        {
            var txtCtrl = pnl.FindControl("TextBox1") as TextBox;
            if (txtCtrl != null)
            {        
                chkCtrl.Attributes["onclick"] = 
                    String.Format("toggleInputEnabled(this, '{0}');", txtCtrl.ClientID);
            }
        }
    }
    

    I’m not too familiar with the TabContainer, but I think the above code should be pretty close. If only the active tab gets rendered, just remove the loop and find the controls in the active tab.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application I have methods which returns a control (checkbox, radiobutton, textbox) but
I have an Asp.Net repeater, which contains a textbox and a checkbox. I need
I have a HTML checkbox which will perform a simple validation on another textbox,
I have a gridview which contains controls like checkbox dropdownlist textbox etc.. These controls
hello everybody i have a listbox within which is a datatemplate.Inside it is checkbox,textbox,label...Wat
I have a Custom Control that has multiple textbox fields and a checkbox contained
I have a checkbox in GridViewColumn which i use for show/change database value. The
I have a textbox control and a checkbox list control on my page. I
I have a view with a form..this form has a textbox and a checkbox
I have added a textbox, a dropdownlist, a checkbox, a button, and an update

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.