0

Hello my fellow Daniwebers,

I have a question for you.

I have an asp.net page that contains a structure that looks like so:

<asp:MultiView>
    <asp:View>
        <asp:UpdatePanel>
            <asp:Panel>
                <asp:TextBox ID="txtStartDate" 
                             runat="server"
                             AutoPostBack="true" />
                <asp:TextBox ID="txtEndDate" 
                             runat="server"
                             AutoPostBack="true" />
            </asp:Panel>
        </asp:UpdatePanel>
    </asp:View>
</asp:MultiView>

The curious problem is that I can't reference the two controls.

(The code behind is vb.net)

I have used:

txtStartDate.Text

and

Dim txtStart as TextBox = FindControl("txtStartDate")
Dim txtStart as TextBox = panelName.FindControl("txtStartDate")

To no avail.

Some times they will retrieve the control, but most of the time they will return null values.

Has anyone else had this issue before?

If so, can you please shed some light on my situation?

I would greatly appreciate it!

Thank you,
Begginnerdev

3
Contributors
8
Replies
9
Views
5 Years
Discussion Span
Last Post by Begginnerdev
0

have you tried

PanelID.FindControl("txtStartDate")
?
you might have to drill down from the view and/or multiview.

0

I have tried stepping all the way down the page's structure to no avail.

It works some times, then other times it just returns null and throws a null reference exception when I try to perform any actions with/against it.

1

Shouldn't the controls in the UpdatePanel be inside of a <ContentTemplate> tag?

0

They are, I had forgotten to add them. (Don't want to copy/paste 400 lines of asp markup)

Sorry!

0

Thank you for the link.

I have tried this and it is still returning a null reference.

The page validates before getting searched, could this cause a null reference?

(Some what new to ASP)

1

are you creating any of these controls dynamically or are they all defined on the .aspx page? With the MultiView all of the controls are present on the page that are defined in the view. It should just be a matter of accessing it like any other control. TextBox1.Text or DropDownList1.SelectedValue, for example.

0

Sorry for my leave of absence.
I have found the solution; the controls were being disposed then recreated in code. (No clue why he did this.)
Changed the disposing to clearing all controls and it works fine!
Thank you for your help!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.