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 9218007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:45:47+00:00 2026-06-18T02:45:47+00:00

I have a tabcontainer with 3 panels and each one has a a few

  • 0

I have a tabcontainer with 3 panels and each one has a a few textboxes and a submit button. I want to store the values of textboxes in a variable on button click. I am getting null value exception at fname = txt.text;

Source:

       <body>
    <form id="form1" runat="server">
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1"   runat="server">
        </asp:ToolkitScriptManager>
    <div>

        <asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" 
            style="margin-right: 38px"  Height="138px"  Width="402px">
            <asp:TabPanel runat="server" HeaderText="TabPanel1" ID="TabPanel1">

              <ContentTemplate>
<asp:UpdatePanel ID="updatePanel1" runat="server"><ContentTemplate><table><tr><td>First Name:</td><td><asp:TextBox ID="txtName" runat="server" /></td></tr><tr><td>Address:</td><td><asp:TextBox ID="txtAddress" runat="server" /></td></tr><tr><td><asp:Button ID="Button1" runat="server" Text="Submit" 
                                        onclick="Button1_Click1" /></td></tr></table></ContentTemplate></asp:UpdatePanel>
</ContentTemplate>

</asp:TabPanel>

            <asp:TabPanel ID="TabPanel2" runat="server" HeaderText="TabPanel2">
            <ContentTemplate>
                    Email: <asp:TextBox ID="txtEmail" runat="server" />


</ContentTemplate>

</asp:TabPanel>
            <asp:TabPanel ID="TabPanel3" runat="server" HeaderText="TabPanel3">
            <ContentTemplate>
                 <table>
               <tr> <td>User Name:</td><td><asp:TextBox ID="txtUser" runat="server" /></td></tr>
               <tr> <td>Password:</td><td><asp:TextBox ID="txtPass" runat="server" /></td></tr>

</ContentTemplate>

</asp:TabPanel>
        </asp:TabContainer>

    </div>
    </form>
</body>

 C# Code:



protected void Button1_Click1(object sender, EventArgs e)
{
    string fname = "";
    string address = "";
    Button btn = (Button)sender;

    TextBox txt = null;
    TextBox txt1 = null;


    txt = (TextBox)TabContainer1.Parent.FindControl("txtName");
    txt1 = (TextBox)TabContainer1.Parent.FindControl("txtAddress");
    fname = txt.Text;
    address = txt1.Text;
    DataTable dt = new DataTable();
    string q = "insert into tabtable (firstname,address) values('" + txt + "','" + txt1 + "')";
    dboperation dbo = new dboperation();
    dt = dbo.insert(q);
}
  • 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-06-18T02:45:48+00:00Added an answer on June 18, 2026 at 2:45 am

    You should be able to reference this control directly since neither TabContainer nor TabPanel implements INamingContainer. Hence the TextBox is on top of the page:

    so instead of

    txt = (TextBox)TabContainer1.Parent.FindControl("txtName");
    fname = txt.Text; 
    

    just

    fname = this.txtName.Text;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have many tabs in tabcontainer on my asp page. I want to set
Looking for some implementation advice: I have a page that has a 3-tab ajaxToolkit:TabContainer.
I have a tabcontainer which contains 5 tabs. I want to clear all data
I have a TabContainer with different tabs (ContentPanes). I am loading each type dynamically
I have two tab panels, and in each of these there is a user
I have used Ajax Tab Control in one of my pages. It has got
I have a TabContainer with three pages of input fields. For each TabPanel there's
I have a tab container with 5 tabs, each tab contains an update panel.
I have an AjaxControlToolKit TabContainer with 2 tabs that I load via a custom
I have an ASP.NET page that uses the ASP.NET Ajax Control Toolkit TabContainer .

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.