Element are reported to be "not declared"

A

AAaron123

The aspx file includes the following:

<asp:LoginView ID="LoginView1" Runat="server">

<LoggedInTemplate>

<fieldset>

<asp:label id="message1" runat="server" />



The .vb file includes in a method

If (ChangePassword1.CurrentPassword.ToString() =
ChangePassword1.NewPassword.ToString) Then

Message1.Visible = True



Both Message1 and ChangePassword1 are reported to be "not declared"

The drop down list in the .vb file does not show them.
They were typed as shown, not draged from the toolbox.
The loginView1 does show in that drop down list.

Does any of this make sense to you?
Do you know what I have that is wrong?

Thanks in advance
 
N

Nathan Sokalski

I've seen it happen before, although I'm not exactly sure why (I think
sometimes it can happen if you add the control using copy and paste, but
once again, I'm not sure). But it is usually because the controls are not
declared correctly in the *.aspx.designer.vb file. To get the
*.aspx.designer.vb file updated, here are some of the ways that sometimes
work (since the *.aspx.designer.vb file is intended to be automatically
generated rather than manually updated, I'm not going to promise anything):

1. Open the *.aspx file and switch between design and source views
2. Open the *.aspx.designer.vb file and update it manually (note that these
changes will be overridden the next time the *.aspx.designer.vb file is
generated)
3. Open the *.aspx file and remove and add the controls again; it is usually
more guaranteed to update the *.aspx.designer.vb file if you do this using
the ToolBox or IntelliSense
4. Close and reopen Visual Studio

All of these suggestions are simply things I sometimes try when I come
across the situation you mentioned, so they are purely from experience and I
have done no testing on when and whether they always work, so hopefully they
will work for you. (NOTE: I use Visual Studio 2005, but unless the bug is
100% fixed in 2008 it will probably apply mostly the same there). Good Luck!
 
M

Mark Fitzpatrick

Because it's in a template, you can't reference it directly. Try using the
LoginView1's FindControl method to gain access to the control in the
template.

Hope this helps,
Mark Fitzpatrick
 
A

AAaron123

I didn't know there was an *.aspx.designer.vb file.
They do not show in my solution explorer.
Now that I know that, I can find much info relating to it.
(In fact, others have discussed the very topic of this thread.)
However, no where do I learn how to display those files.
I played with the "show all files" and also searched for *.aspx.designer.vb
in help.
Got many hits but I guess everyone figures that how to display those files
in the solution explorer is obvious.

Can you tell me how to make those file names show?

Thanks
 
N

Nathan Sokalski

There are several ways to view the *.aspx.designer.vb file. Here is a quick
list:

1. In the Solution Explorer, right-click the *.aspx file and select "View
Code Gen File"
2. In the Solution Explorer, select "Show All Files" (this is the second
icon from the left, but it sounds like you know about Show All Files). The
*.aspx.designer.vb file will be listed with it's associated *.aspx file, you
may need to click the +/- next to the *.aspx file to see it.

If both of the above fail, check the following:

1. Although it is not the default and is not recommended, I believe there is
a way to have the code that would normally be in the *.aspx.designer.vb file
automatically added to a REGION in the *.aspx.vb file like it was back in
ASP.NET 1.1, but I would assume you would have noticed it there if that were
the case.
2. View the directory of the project using Windows Explorer to see if the
file really does exist (I don't know why it wouldn't, but there is probably
a setting somewhere in Visual Studio that I can't find that allows you to
have the *.aspx.designer.vb file not automatically generated)

If all of these fail, I am not sure what to do. Hopefully now that you know
about the file you can manage to find something on the web or possibly
posting a new post with a more specific subject you will get some better
responses. Good Luck!
 
A

AAaron123

Thanks, I want to finish looking at why I don't have *.aspx.designer.vb
files; then I'll try that.

Thanks again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top