Hey everyone; I wrote up a custom control that inherited from a textbox, with a public method. It worked great in a test .aspx page, so I added a second instance right below the first. What's strange is that I can only call the first object's method. Even Intellisense will display the method name. But when I try to call the second object's method, I don't get any Intellisense help, and I get the error message "\\testcontrol.aspx.cs(64): The type or namespace name 'TomsTextBox2' could not be found (are you missing a using directive or an assembly reference?)" What am I missing?
At the top of the testcontrol.aspx file, I have this in the HTML:
<%@ Register TagPrefix="TomsControls" Namespace="testcustomcontrols" Assembly="testcustomcontrols" %>
Then I added the controls to the page, one after the other, like this:
<TomsControls:FunnyTextBox id="FunnyTextBox1" runat="server" FunnyColor="blue"></TomsControls:FunnyTextBox>
<TomsControls:FunnyTextBox id="FunnyTextBox2" runat="server" FunnyColor="blue"></TomsControls:FunnyTextBox>
Finally, I tried to do this in the codebehind:
private void btnSubmit_Click(object sender, System.EventArgs e)
{
FunnyTextBox1.FlipColor();
FunnyTextBox2.FlipColor();
}
When I type "FunnyTextBox1.", Intellisense shows me the FlipColor() method. When I type "FunnyTextBox2.", I don't get anything. If I finish the line so it reads "FunnyTextBox2.FlipColor()", and try to build the solution, I get the error mentioned in my first paragraph above.
Here's the strange part! By random flipping back and forth between the code-behind .aspx.cs file, and the .asp's html view, I tried changing the id of the second control to "FunnyTextBox3" inside the HTML.
I went back to the .aspx.cs code-behind, and I still couldn't access FunnyTextBox3.whatever. No intellisense, and I still get an error when I try to build the solution.
I went back to the .asp page, in design view, and changed the second control's id back to FunnyTextBox2. I clicked on the HTML view, and yes, the property of the control shows that the id -is- FunnyTextBox2. So I went back to the code behind file.
When I type "this.", Intellisense now shows me "FunnyTextBox1", "FunnyTextBox2", AND "FunnyTextBox3"!! What the HECK is going on here? If I rebuild the solution, all three still exist. If I try referencing funnytextbox3.flipcolor(), it builds okay- and of course, it fails when the project runs.
What happens to Visual Studio .NET 2003 when I flip between "Design" and "HTML" view of an .aspx file?? Am I supposed to recompile that file only? Is this a bug in the IDE?
I've even tried exiting VS.NET, exiting VS.NET and logging out and logging back in, and exiting VS.NET and rebooting- same thing. The second control ID is always erratic. Any and all help would be appreciated!
Thanks!!
-Thomas