ASP.net - How to access controls in VB.net code behind

GIANTOCR
GIANTOCR used Ask the Experts™
on
I am working on an ASP.net project in VS 2008, using Visual Basic. This project was started by someone else.

I have added some new controls to an existing UpdatePanel. I am unable to access the new controls in the visual basic code behind. When I type in the controls' names I would expect Intellisense to recognize the control and allow me to access its methods, properties and whatnot.

Strange thing is that the existing controls that were in the Update Panel before I started modifying it are accessible through Intellisense in visual basic.

I can not find where the settings for the existing controls are any different from the new controls.

<asp:UpdatePanel ID="SeriesUpdatePanel" runat="server" 
        UpdateMode="Conditional" ChildrenAsTriggers="False" >
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="ButtonIndexChanged" EventName="Click" />
    <asp:AsyncPostBackTrigger ControlID="RemoveSeriesButton" EventName="Click" />
    <asp:PostBackTrigger ControlID="SeriesEditOK" />
    </Triggers>
    <ContentTemplate>
        <asp:Panel ID="seriespopuppanel" runat="server" class="seriespopuppanel" 
        Height="339px" Width="281px">
        <table>
                    </tr>
                        <tr>
   
                <td class="style2" colspan="3" style="width:80%;">
                    <table style="width:100%;border:solid"><tr><th>Edit Data Series</th></tr></table></td>

            </tr>
            <tr>
                <td class="style1">
                    <asp:ListBox ID="SeriesListBox" rowspan="3" runat="server" onchange="IndexChanged()"></asp:ListBox>
                </td>
                <td class="style2">
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style1">
                    </td>
                <td class="style2">
                    Visible</td>
                <td>
                    <input ID="VisibleCheckbox" type="checkbox" runat="server"/></td>
            </tr>
            <tr>
                <td class="style1">
                    &nbsp;</td>
                <td class="style2">
                    Show Limits</td>
                <td>
                    <input ID="ShowLimitsCheckbox" type="checkbox" runat="server" /></td>
            </tr>
                        <tr>
                <td class="style1">
                    <asp:Button ID="SeriesEditOK" Text="OK" Width="60px" runat="server" onclientclick="UpdateSeriesProperties()"/>
                            </td>
                <td class="style2">
                    Show Marker</td>
                <td>
                    <input ID="ShowMarkerCheckbox" type="checkbox" runat="server" /></td>
            </tr>
                        <tr>
                <td class="style1">
                    &nbsp;</td>
                <td class="style2">
                    Y Axis</td>
                <td>
                    <select ID="YAxisSelect" name="D2" runat="server">
                        <option>1</option>
                        <option>2</option>
                    </select></td>
            </tr>
            <tr>
                <td class="style1">
                    &nbsp;</td>
                <td class="style2">
                    Autoscale</td>
                <td>
                    <input ID="AutoScaleCheckbox" type="checkbox" runat="server" /></td>
            </tr>
            <tr>
                <td class="style1">
                    &nbsp;</td>
                <td class="style2">
                    Y Axis Min</td>
                <td>
                    <asp:TextBox ID="AxisMinTextBox" runat="server"></asp:TextBox>
                </td>
            </tr>
                        <tr>
                <td class="style1">
                    &nbsp;</td>
                <td class="style2">
                    Y Axis Max</td>
                <td>
                    <asp:TextBox ID="AxisMaxTextBox" runat="server"></asp:TextBox>
                            </td>
            </tr>
                        <tr>
                <td class="style1">
                    <asp:Button ID="SeriesEditCancel" runat="server" Text="Cancel" Width="60px" />
                            </td>
                <td class="style2">
                    <asp:Button ID="RemoveSeriesButton" runat="server" Text="Remove" />
                            </td>
                <td>
                    <asp:Button id="ButtonIndexChanged" Text="Index Changed" style="display: none;" OnClick="SeriesListBox_SelectedIndexChanged" runat="server" />
                    </td>
            </tr>
                        </tr>
                        <tr>
                <td class="style1">
                    &nbsp;</td>
                <td class="style2">
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>
    </asp:Panel>
    </ContentTemplate>
    </asp:UpdatePanel>

Open in new window


In the code above, all the controls are accessible with the exception of "AutoScaleCheckbox", "AxisMinTextBox" and "AxisMaxTextBox".

When I type in these control names in visual basic I get the following error:

Name '' is not declared.

I would appreciate any help you can provide.

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2014
Commented:
Are you looking at "All" tab in intellisense window (not "Common" tab)?
If they are checkboxes and textboxes, they should be able to access. What if you drag one textbox onto elsewhere, not into the panel and try?
Gerry BartleySoftware Engineer
Commented:
Weird
I copied your markup to a page and all controls show up in code-behind

Try doing a project rebuild and then try typing the control name in vb again. It sometimes helps!!!!!


although you do have mismatched /tr tags line 12 and line 101?

Author

Commented:
Thanks for the help. I played around and found that no matter where I added a control I could not get to in in code behind.

The website I had open was the same name but different version and folder than one I had previously opened in VS. When I opened it originally VS put a (2) after the name.

I closed the website, saved it with a new name. Then restarted my computer and when I opened the website up again in VS I could add new controls and get to them in code behind.
Yes. That was my intention :). Sometimes, it just gone wild. You found out what happened, congrats. Because from what I see, it isn't possible, they must be able to be accessible.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial