Avatar of GIANTOCR
GIANTOCR
 asked on

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

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
ASP.NETVisual Basic.NET

Avatar of undefined
Last Comment
adriankohws

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Nasir Razzaq

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
adriankohws

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
GIANTOCR

ASKER
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.
adriankohws

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.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes