Textbox control throw System.NullReferenceException when inside Accordion

Last post 05-05-2009 2:27 AM by Vince Xu - MSFT. 4 replies.

Sort Posts:

  • Textbox control throw System.NullReferenceException when inside Accordion

    04-30-2009, 4:43 PM
    • Member
      80 point Member
    • rostam
    • Member since 07-19-2002, 9:12 PM
    • Toronto
    • Posts 34

    I have an accordion control. If I place a simple text box inside it and assign it a value ti will throw an error.

    I assign it a value inside page load.

    I cannot figure it out.

    I am using AjaxControlToolkit version 1.0.10618.0

     

    I know that my value is present when assigning. It happens when setting the textbox.Text property.

    Even if I go textbox.text = "test"; it throws the error..

     --------------------------------------------

    Object reference not set to an instance of an object.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

     --------------------------------------------

     Here is my code:

    <ajaxtoolkit:accordion id="MyAccordion" runat="server" selectedindex="0" headercssclass="accordionHeader"

    headerselectedcssclass="accordionHeaderSelected" contentcssclass="accordionContent"

    suppressheaderpostbacks="true">

    <Panes>

    <ajaxToolkit:AccordionPane ID="AccordionPane1" runat="server">

    <Header>

    <a href="" class="accordionLink">Default Page</a></Header>

    <Content>

    <div style="font-weight: bold;">

    Form Expiration Message</div>

    <div style="font-weight: bold;">

    Forgot Password - Email Subject to Primary Contact</div>

    <asp:TextBox ID="txtPasswordResetEmailSubject" runat="server" TextMode="MultiLine" Wrap="true" Width="500px" Height="55px"></asp:TextBox><br />

    <asp:RequiredFieldValidator ID="rfvEmailSubject" runat="server" ErrorMessage="Cannot be empty" ControlToValidate="txtPasswordResetEmailSubject" Display="Dynamic"></asp:RequiredFieldValidator>

    <asp:Button ID="btnSaveEmailSubject" runat="server" Text="Save" OnClick="btnSaveEmailSubject_Click" />

    </Content>

    </ajaxToolkit:AccordionPane>

    </Panes>

    </ajaxtoolkit:accordion>

    Rostam Jarrah
  • Re: Textbox control throw System.NullReferenceException when inside Accordion

    04-30-2009, 9:05 PM
    • All-Star
      27,952 point All-Star
    • bmains
    • Member since 10-22-2004, 12:20 PM
    • Posts 5,639

     Hey,

    Could you post a code sample?

    Brian

    "Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4).
  • Re: Textbox control throw System.NullReferenceException when inside Accordion

    05-01-2009, 8:32 AM
    • Member
      80 point Member
    • rostam
    • Member since 07-19-2002, 9:12 PM
    • Toronto
    • Posts 34
    Hello Brian: the sample code is in the my post.
    Rostam Jarrah
  • Re: Textbox control throw System.NullReferenceException when inside Accordion

    05-01-2009, 8:36 AM
    • Member
      80 point Member
    • rostam
    • Member since 07-19-2002, 9:12 PM
    • Toronto
    • Posts 34
    Here is my page load where I assign the vale: protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { txtPasswordResetEmailSubject.Text = "test"; } }
    Rostam Jarrah
  • Re: Textbox control throw System.NullReferenceException when inside Accordion

    05-05-2009, 2:27 AM
    Answer

         Hi,

    Please use the following code instead.

     ((TextBox)AccordionPane1.ContentContainer.FindControl('txtPasswordResetEmailSubject')).Text = "test";


    Vince Xu
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Page 1 of 1 (5 items)