I have just inherited a Xamarin project that keeps the Views (.xib) in a separate folder from the controllers. I find it a little difficult to scroll through the left menu and try to match up the nib files to their controller. So I put the nib files right next to the controller cs file and in the same folder that's organized by domain.
My question is, is there a good reason why they were separated out in the first place? I know a typical MVC application will do this but this is a bit different because a nib file needs to declare the controller.
No good reason that I can think of. It shouldn't matter either way. It's mainly organizational preference. I typically like to keep them together as well.
Related
I'm enjoying using the well-made MVCSiteMapProvider through Nuget at the moment but I've hit a roadblock.
I'm trying to modify the template for the #Html.MvcSiteMap().Menu() helper. The file I'm modifying is ..\Views\Shared\DisplayTemplates\MenuHelperModel.cshtml and no matter what change I make to the file, the template does not update when rendered.
I've done a Find All with notepad++ and found that within MvcSiteMapProvider.dll there is two templates, one for classic asp.net and one for Razor. So clearly the template within the .dll file is being called - but how do I make this not the case?
It may be worth knowing that although the templates are located in ..\Views\Shared\DisplayTemplates\, the site is configured to use a different folder for Views.
edit: also if I pass in a template name to the helper, still no effect.
Templated helpers are an MVC creation, not one of MvcSiteMapProvider. I strongly suspect your issue is due to reconfiguring your Views folder. MVC does not support a way to reconfigure your templates folder.
But as pointed out in the accepted answer, it is possible to put them under ~/Views/CurrentController/DisplayTemplates/. You might be able to use that feature to put the templates in your newly configured folders. This means that you would need to add a copy of the templates for every single controller, though.
The best solution is not to change the MVC folders from their defaults.
If that is not an option, you might consider rolling your own Menu HTML helper based on the code from the current one that returns an HtmlString rather than using templates.
The templated helpers are better because you can edit the code after it is deployed (which is why we did it that way), but it comes with the caveat that you have to rely on MVC's default folder structure to use them.
I've been learning MVC3 a bit for a while and although I understand most of the basics, the routing is something I just can't seem to get a hang off. I'm not sure whether I'm doing/thinking it in a correct way and the other answers I've read on stackoverflow/google only seem to confuse me more.
Anyway here's the situation. I've got a solution (cleaned it up for this question), where I'd like to create a structure in my views folder to organize everything in a structure I've been using for my asp.net webforms projects.
Anyway, I was wondering whether it would be possible to get this kind of structure, where I could organize all my partial views into a specific subfolder called UserControls in which there are more subfolders where I would group every partial view I'd need for a specific page.
Ideally, my Views folder would contain 2 folders: Pages and UserControls and everything I'd need would go into a subfolder, or a sub sub folder.
Okay so if this is possible, how would I start routing this? I've been trying multiple ways of getting any result but they all end up in a 404 errors.
If this is a wrong approach of me, what would be a better alternative?
Thanks in advance!
Logically, this is better served by grouping your partials in with the actual views like so:
/Other
/Partials
OtherPartial1.cshtml
OtherPartial2.cshtml
Index.cshtml
/Some
/Partials
SomePartial.cshtml
Index.cshtml
SomeOtherView.cshtml
Now, you can certainly do as you suggest, but it simply means that your helpers in other views have more text to write to get where they want to go:
IE.
#RenderPartial("Partials/OtherPartial.cshtml")
VS
#RenderPartial("~/Views/PartialControls/Other/OtherPartial.cshtml")
You could manually return the view file for each actionresult or partialactionresult.
I'd also recommend changing "UserControls (PartialViews)" folder to just PartialViews.
e.g.
public PartialViewResult OtherPartialView1()
{
return PartialView("../PartialViews/OtherViews/OtherPartialView.cshtml");
}
I am currently working on an mvc4 application. It needs to be multi lingual so therefore each of my views requires a resource file associated to it.
In the web forms world, I would be creating App_LocalResouces and have the resource files within this for my pages/user controls.
Being new to MVC I am not sure how this works - is it similar. For example for my razor views, where the resource file for the particular view reside. Same with my models and controllers, where does the resource file for such reside?
I've seen it done a lot of ways. It's really based on preference. My preference is to create a Resource folder and store the translated strings in one file with the name of the culture. I then set the language in the web.config file and leave it up to the page to pull the correct strings.
# Scenario large Enterprise project.
If puts files in different folder, then solutions becomes very slow while build/debugging, also searching file in folder directory is painful sometimes.
If puts files in different web project then it is heard to manage .config, theme/master-page, App_code, image-folder etc.
I would greatly appreciate your suggestion & guideline.
Thanks.
Don't try to make your dev life more difficult if you don't see reasons to do this. :)
You should not separate UI in your folders if you will not need to reuse some components in separate project. so definitely don't separate your application by projects if you don't see reasons for that.
This is strange that when you've added files in different folder and solution becomes slower to build / debug. What type of project you use? WebSite or WebApplication?
I always separated in folder tree my ASP.NET pages / controls by very similar to site structure scheme. So if I have tree pages for users, like UserView / UserEdit and UserList - I do the folder Users and place here these tree views and maybe some UserControls which are related to these views.
I have an application lets say "Application1" .I want to install same application but by changing some contents in it and also its name like "Application2" so that both application1 and application2 can be seen on device?
Is this possible?If yes,then can someone kindly help as to how to do it.
EDIT:
Just if somebody else might need it, I got this done.
Get a GUID from a GUID generator tool and use this new GUID in WMAppManifest.xml and replace ProductId in this file and GUID in AssemblyInfo.cs.Rebilud the solution and its done!
Creating a new app with exactly the same content is very easy:
Create a new project and name it with the new name.
Remove the pages/classes created by default in the new project.
"Add as Links" all the pages/classes from the original project.
If you want to have different content in the second app, just put the different content in a separate file and use that rather than a linked one. (Partial classes split across multiple files make this very easy.)
Another way to customize content in the second app is to define a partial method in the original app but only implement this in the second app (in a partial class/file which only exists in the second app). In the implemented partial method add your changes to override the default (original app) behaviour/layout/whatever. - This is a good way of altering pages where you don't want to have to put customization into an already existing app. You just "override" it in the second app.
You would need to submit the two slightly different applications to the market as separate applications in order for them to be seen on the user's device.
As Matt suggests, if the two applications have a lot in common, then you can use linked files to reduce your maintenance overhead.
In addition to Matt's suggestion, I've done this for Free/Paid versions of the same app.
It's pretty easy to do. The files to change between versions are:
the icons
the splash screen
the mobile XML file in the Properties folder
The important thing in the XML file is the GUID identifying your app. This GUID doesn't seem to be used in the Marketplace - but it is used by the debugger's deployment functionality.
You can also use a project level #define to include/remove any other code you want different between the projects.