I am using .NET2.0. Let’s say a have a simple aspx form with txtInput and btnSomeAction
<asp:TextBox ID='txtInput' runat='server'></asp:TextBox> <asp:Button ID='btnSomeAction' runat='server' CommandName='SomeAction' Text='Do'/>
Then within the code behind the form I have
Protected Sub btnSomeAction_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSomeAction.Click Dim s As String s = txtInput.Text End Sub
It all works fine.
Then I want to add the code to a custom namespace like
Namespace mycustomnamespace
When doing that I would get a complier error:
Name ‘txtInput’ is not declared – as if the code was no longer connected to the page
Do i need to modify the aspx page to include the namespace?, What about the partial class?
Yes. At the top of your aspx file you should see something like
Where bar is the name of the class in the codebehind and Blah.Foo is it’s namespace. You would need to change it to