Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Name Name 'XXX' Not Declared
Previous
 
Next
New Post
12/8/2009 2:55 PM
 

Hi,

I am getting the above error in the code behind file of a Web user Control. For example, if I have a textbox on the .ascx file with an ID= txtWebsite (note this is occuring with any control that I put on the .ascx page, DataGrid, Repeaters, etc) in my code behind file I will get the error "Name 'txtWebsite' not declared. The way I am attempting to develop a module is based on the Wrox Professional DotNetNuke Module Programming Book.


txtWebsite is declared, so I am not sure what is causing this. The only thing I have been able to determine, through extensive googling is that the .ascx.designer.vb file is no longer associated with its parent, in this case the .ascx file.  In the DNN project I have the designer is no longer showing up as a child to the .ascx file, rather it is inline with is, somewhat like this:

[code]
<a.ascx>
      <a.ascx.vb>
<a.ascx.designer.vb>
[/code]

When it should be:

[code]
<a.ascx>
      <a.ascx.vb>
      <a.ascx.designer.vb>
<b.ascx>
[/code]

Here is a code snippet from the .ascx defining the txtWebsite:

[code]
            <td>
                <asp:TextBox ID="txtWebsite" runat="server" MaxLength="255" CssClass="NormalTextbox" />

[/code]

And the corresponding .ascx.vb saying where it says txtWebsite is not defined:

[code]
                oInfo.SubmitterWebsite = Server.HtmlEncode(txtWebsite.Text)
[/code]
 

I have tried taking the code from the ascx.designer.vb, per one solution I thought I had found, and putting it directly into the ascx.vb file and then changing the partial class into a normal class, but that just ended up breaking more stuff. Any ideas on either how to get the designer.vb to be associated with its parent correctly or some other way to fix this?

Any help would be much appreciated.

Thanks,

Chris

 
New Post
12/8/2009 9:00 PM
 

Occasionally the designer file will get out of sync or not be properly associated with the .ascx user control. To restore the association and recreate the designer file you can try the following:

1. Verify that the @ Control directive in the .ascx includes a Codebehind attribute (NOT Codefile) referencing the .ascx.vb file. For example: Codebehind="a.ascx.vb"

2. Verify that the @ Control directive in the .ascx includes an Inherits attribute whose value matches that of the class's full name including namespace.

3. Switch from Source to Designer view then back again. This should force updating of the designer file - but doesn't always.

4. If #3 did not resolve the problem, right click over the user control filename in Solution Explorer. If the context menu contains the item "Convert to Web Application Project", click on that menu item. This should force creation of the designer file.

5. If #3 and #4 did not work, try a) deleting the designer file then b) cutting all contents of the .ascx file to the clip board then immediately pasting it back into the .ascx file. This also should force creation of the designer file.


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
12/9/2009 9:15 AM
 

Hi William,

Thanks for the response,  I confirmed #1 and #2 and both are correct, I tried switching from source to designer, It did take a second to load up the designer but did not do anything for the issue at hand. For #4 I only have the option to Build Page. If I open the Project in its own VS instance, I am able to do Convert to Web Application Project, but the error still shows up.

Deleting the designer file and cutting and pasting the contents didnt do anything either, the designer file would not repopulate, so I had to open the project up and do the "convert to web application project" to get it to show up in my DNN website install.

As another note, If I try to create a Web User Control from the DNN install in my module, so then I can just copy and paste the code to the new one and get rid of the non working one, I only get the .ascx file showing up, I am unable to find/access the ascx.vb file.

 

Chris

 

 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Name Name 'XXX' Not Declared


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out