Module name with a dot creates invalid code behind class name

May 4, 2007 at 5:09 AM
I named my modules with the convention of RootNameSpace.ModuleName. This causes the add view with presenter recipe to create a code behind with a class name that has RootNameSpace.ModuleName_PageName which doesn't compile due to the dot in the class name.
Developer
May 4, 2007 at 3:01 PM
Hi royhiggs,

Thanks for the feedback, you have found an issue. I created the WorkItem 10082 for this.

By default, WCSF doesn’t let you create modules with names with dots, but if you rename the module in your solution, and then add a view, the view is added with a wrong class name as you said.

To solve the problem for creating future views:

  1. Go to the %programfiles%\Microsoft Web Client Factory\WCSF Guidance Package\Templates\T4\View.
  2. Open View.aspx.cs.t4 file.
  3. Replace “<#= this.ModuleName #>” with “<#= this.ModuleName.Replace(".", "_") #>” beside “public partial class”.
  4. Save the file.
  5. Open View.aspx.t4 file.
  6. Replace “<#= this.ModuleName #>” with “<#= this.ModuleName.Replace(".", "_") #>” beside “Inherits=”.
  7. Save the file.

After that if you Add a view for module with the name “RootNameSpace.ModuleName”, your view class name should be like “RootNameSpace_ModuleName_PageName"

Please let me know if this helps,
Ezequiel Jadib
http://staff.southworks.net/blogs/ejadib
May 6, 2007 at 4:49 AM
Thanks, this worked great. I also poked around in the t4 files and updated some other items like the name of my master page so I don't have to change that when I create a new view now. Cool stuff!!! :)