Customize List.aspx for One Table in ASP Dynamic Data - asp.net

I have just meticulously followed MS instructions for customising a dynamic data page template for one table. Create the folder CustomPages/MyTable/List.aspx, and copy PageTemplates/List.aspx into that folder, but I now get compiler error because I have duplicated methods in both List.aspx files.
What am I doing wrong?
Just in: I found another, non-MS page that I can't find again now, but he suggested the almost obvious: to change the class name in thej 3 files of my custom list page.

I'm not sure what it says in the instructions, but you'll need to change the namespace in the two codebehind files (List.aspx.cs and List.aspx.designer.cs) and in the "inherits" reference in the .aspx file or yes, you will have duplicate methods (same namespace, same class name, same method name).
You should change the namespace to reflect the path that the custom page is in - this will help ensure it stays unique.

Related

Adding a masterpage to already existing pages

I'm wondering how this can be done because I need this for a school project so it is easier to get a translating system done.
Go to the "Page" prefix of your page, the first line of the .aspx file. And add "MasterPageFile" attribute into it, and choose the Masterpage you want to bind.

Plone setuphandler- In a setuphandler, how can I programatically add/create a folderish content type at root of Plonesite?

I have have made a folderish content type called supplier_folder, which displays a list of suppliers that can be added under it, and their information. I can add it through the navigation bar, but I would like to add it programatically during setup.
I have been following the tutorial on custom installer code (http://docs.plone.org/develop/addons/components/genericsetup.html#custom-installer-code-setuphandlers-py) and have looked at creating objects programatically (http://docs.plone.org/develop/plone/content/creating.html).
Unfortunately, the second article says I need to have a folder created. How can I get around this and add the supplier_folder object at the Plone Site outside of a folder?
IIRC, only users with role Manager or Site Administrator can add content to the root of the site; you can overcome this limitation in two ways:
by using the _constructInstance method as it bypasses the permissions when creating an item
by switching roles inside your code with plone.api.env.adopt_roles
I personally prefer the second one.
you can see an example of a pretty complex setuphandlers.py in interlegis.portalmodelo.policy package.
When you create a new Plone site, it's also creating some default content types.
Look at how Plone do: https://github.com/plone/Products.CMFPlone/blob/1471828ee97a8dd84396bad4a3286be514819869/Products/CMFPlone/setuphandlers.py#L119
There are a couple of ways to achieve this. The buildin mechanism is to use GenericSetup in combination with "structure" folder as described here: http://koansys.com/tech/create-plone-initial-content-with-generic-setup
In short you need the following:
Create a folder "structure" in your Generic Setup profile (in general, under profiles/default)
Create a .objects file with the following content: "suppliers,supplier_folder"
in "structure" create a folder "suppliers" with a .properties file and content:
[DEFAULT]
title = Suppliers
description = Some usefull description text
As far as I remember this is ok for simple structures likes your. If you have complex structures with folders and sub-folders and want more specific control you probably need to write python code. I made some stuff here: https://github.com/collective/zettwerk.setup/blob/master/zettwerk/setup/structure.py
But zettwerk.setup is not yet released, but you should be able to integrate the structure.py right into your project. Than you can the handle_structure method into your setuphandlers.py and passing a structure dict like this:
handle_structure(portal, [{'id': 'suppliers', 'portal_type': 'supplier_folder'}])
The advantage of this method is, that you can also control metadata like workflow state, default page setting, portlets, local roles and some others.

How edit code template ASP MVC 4 CRUD Generator?

I want to alter the default code genaration of MVC CRUD ASP . NET.
Visual Studio.It generates pages of "Edit.cshtml/Insert.cshtml/Delete.cshtml"
I want to translate "Edit" to "Alterar" - "Insert" to "Inserir", and I would like that the razor file to be called "Alterar.cshtml" instead of "Edit.cshtml"
How can I do that?
Is it possible?
Yes, you can.
Based on this excellent blogpost by Scott Hanselman I changed the default template in a few steps. The difference between Scott's approach and mine is that he apparently made it in a way that keeps the global default but gives him a separate generator for each project. Since I didn't get it working immediately, I opted to instead just change the global template.
Go to C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ItemTemplates\CSharp\Web\MVC 4\CodeTemplates\AddController (some parts of the URI may vary in your situation
Optionally: grant yourselves write privileges on Controller.tt
Open Controller.tt in an editor of your choice and change what you want to change. Note that these are T4 templates so you have a wide variety of tools to your disposition if you want to do more advanced stuff.
Create a new ASP.NET MVC project
Go to the "Controllers" folder and add a new controller (not an api controller)
You don't have to change anything to get a differently named view: the view, including the file in which it is stored, is generated based on the name of the action method that creates it. If you generate the view from Alterar then the popup window will present you with the name "Alterar" for the file.

Browse for Project Folders in Build Template TFS 2010

I'm adding a new argument to my custom Build template. The argument is almost identical to the default Projects to Build argument under Required -> Items to Build. It simply shows a dialog window with a list of folders under current TFS Project. I can't figure out what the type of control is. I tried FolderBrowserDialog but it browses the computer rather than the TFS project itself. Any help would be appreciated.
You can set the Editor for this argument to:
Microsoft.TeamFoundation.Build.Controls.ServerFileBrowserEditor, Microsoft.TeamFoundation.Build.Controls
Or
Microsoft.TeamFoundation.Build.Controls.ServerFolderBrowserEditor, Microsoft.TeamFoundation.Build.Controls
See my blog for a detailed set of steps.
All of these types are Internal, so you can't reference them from your own code or see them easily. What you can do, is set them as Editor for a parameter you created in the Build Workflow. You need to specify Typename, Assemblyname. You can find these items in the MetaData section of your Build Template.
Add your argument to the workflow:
Open the Metadata property:
Set the editor for your property:
A multi-folder select dialog is not part of the Default UI Editors. You'd have to roll your own. Either use Reflector to see how the existing ones work, or use Reflection to invoke th existing editors as part of your new editor.
It's not going to be pretty code either way, but it would work.

How to deal with Web Controls in a class library which have file dependancies

I could do with a little guidance if possible..
I'm building a class library to contain custom web controls. I've transformed many of the jQuery UI elements into .NET classes for dynamic use in pages. e.g.
Dim Msg As New Dialog("Dialog Title", New LiteralControl("Dialog Content"))
Msg.Width.Value = 500
Msg.Height.Value = 300
Me.Controls.Add(Msg )
The necessary scripts get inserted into the head during CreateChildControls, and any jQuery file references are added to the head e.g.
RegisterScriptFile("~/Scripts/jquery-1.5.1.js")
RegisterScriptFile("~/Scripts/UI/jquery.ui.core.js")
RegisterScriptFile("~/Scripts/UI/jquery.ui.widget.js")
RegisterScriptFile("~/Scripts/UI/jquery.ui.mouse.js")
RegisterScriptFile("~/Scripts/UI/jquery.ui.draggable.js")
RegisterScriptFile("~/Scripts/UI/jquery.ui.position.js")
RegisterScriptFile("~/Scripts/UI/jquery.ui.resizable.js")
RegisterScriptFile("~/Scripts/UI/jquery.ui.dialog.js")
The WebControl base class handles inserting the references into the Page Head.
This is brilliant, however there's a problem...the file paths may differ between applications which consume the control library.
My choices that I can see are:
A) Embed the files as resources within the library itself....however the CSS styling would be non-customisable between the individual aplications, and any changes to CSS/JS would need a re-compile.
B) Define and use a standardised file heirarchy. Each application needing a folder call 'Scripts' with a fixed file heirarchy within, so the control knows where to reference the required files. The problem I can see here is that it might not always be possible to use this standardised heirarchy and could make using the library cumbersome.
C) Create a property for each control, for each file it requires. Again this would become cumbersome and a pain to use, because each instantiated control would have to have those properties set.
D) Make some kind of ResourceUrlLibrary Dictionary like class which the consuming app can populate, then give to each control as it's instantiated. However, this seems convoluted and could cause confusion for other developers.
If anyone has come across this problem and could spare me some guidance that would be brilliant :)
If its a custom control, it has a reference to the Page class, which then has a method call ResolveClientUrl to generate a relative URL for you. So that can take care of that scenario. You may want to expose a ScriptsFolder property that allows you to store the path to the scripts rather than hard-coding it too.
If this is for your own custom project, standardizing on a folder is fine, but if you are creating a common library to be reused, requiring a specific folder isn't a good idea, and you can then use the ScriptsFolder property to remedy this, or store the folder path in the config. It's OK to standardize on the use of an application setting.
To confirm, I use Telerik controls, and they go the route of having a property that defines a custom path to the script (since they rely on one for a specific control), and they also have certain settings that can be overridden by adding an application setting.
HTH.

Resources