I want to use Umbraco .NET Custom Control in Macro.
I have gone through following steps:
1) I have created new Macro with name TestProperty
2) Browse and Add Pramater from Assembly
3) Use Macro in Template
I did not get any problem till last step. But when i am previewing my Content then I am getting Page with Error as Below:
How can I get my Property Value in this case?
TestProperty is an Int. Try
new {TestProperty=2}
See http://blog.darren-ferguson.com/2014/05/13/typed-access-to-umbraco-marco-parameters-in-partial-views/
Related
I have exactly opposite problem to one described here. In my case Visual Studio inserts using directives inside namespace and I want to prevent this. I did try to uncheck Resharper option:
Languages -> C# -> Formatting Style -> Namespace Imports -> Add using directive to the deepest scope
And it didn't help. Also I tried to temporary disable the Resharper. Still same issue.
Btw, I have StyleCop and StyleCop+ installed as well. Maybe it is causing the issue.
So right now when I go and Add New Item -> Class - it will create new code file with using directives inside namespace. How to change this?
Have you replace your class template file with one that has one or more using directives inside the namespace declaration? If so, you're probably seeing the result of an interesting bit of C# plugin behavior: a newly added using directive is placed after the last recognized using directly already in the file, regardless of where that is.
I am using a split page view for one of my page layouts in my Windows 8 app. If I run the app in debug mode the source details are loaded and everything is fine.
However, in my XAML designer view I am unable to bind the data to the view using d:Source & d:DataContext even though I've defined the xmlns:data source.
The error I get is as follows: The name "MyDataSource" does not exist in the namespace "using:MyApp.Data"
Has anyone come across this before?
I figured it out in the end. Rookie mistake, I used the incorrect namespace. Instead of MyApp.Data, I used just MyData in defining the source file namespace model.
The idea is that I'm building a CSS file generating service, it's working just fine. But I need the view file extension to be CSS instead of cshtml so I take advantage of the visual studio intellisense.
Any ideas?
The only way I can possibly think this setup a custom HTTP handler; there you can give it an explicit name, and try giving it a file extension of CSS... Not 100% sure it will work, but you could give it a shot; though you would need to move the code to a class implementing IHttpHandler.
However, I don't think either way will work with Visual Studio Intellisense. If you want intellisense, add the CSS to the markup, then remove it programmatically at runtime. This is one possible way to work around it.
You could create your own ViewEngine which inherits from the Razor View Engine. There you'll need to set the FileExtensions property to include css. Here is a guide to creating it. The other option is to find the Razor View Engine from the View Engines list and try setting it there.
I recently created my first custom control. I attempted to add it in a separate project I have constructed.
I recieve this error:
The type 'System.Windows.Controls.Control' is defined in an assembly that is not referenced. You must add a reference to assembly
Here are the steps I took to add the control.
Add the Custom Control as a Reference in project
Add the attribute xmlns:MyNamespace="clr-namespace:CustomControls;assembly=CustomControls" to the root element of the markup file where it is being used
Rebuild the Controller and the project
You also need a reference to PresentationFramework.dll
In a visual studio project I have three layers, Data Layer, Business Layer and Presentation Layer.
In the Data Layer I have a few XSLT's that transform some objects into an email, all works fine but I have discovered that the XSLTs do not get built/copied when building.
I have currently, created a folder in the deploy location and placed the XSLT's there but I am concerned about relying on a manual process to update these.
Has anyone encountered a similar issue and if so how did they get around it.
It smacks of changing the MSBuild script to copy the build artifacts to the required location, does anyone have examples of this?
Thaks
If you are using Visual Studio 2005/2008, the easiest way to do this is by including your XSLT files as project resources.
Open the Properties for your project.
Select the Resources tab. You will probably see a link that says "This project does not contain a default resources file. Click here to create one." Go ahead and click on that.
Click the Add Resource drop-down near the top and select Add Existing File.
Browse to your XSLT files and select them.
After you have done this, you can easily access the resources in the following manner:
// To get the contents of the resource as a string:
string xslt = global::MyNamespace.Properties.Resources.MyXsltFile;
// To get a Stream containing the resource:
Stream xsltStream = global::MyNamespace.Properties.Resources.ResourceManager.GetStream("MyXsltFile");
If you are using Visual Studio 2003, your best bet is to include those XSLT files as embedded resources for the DLL. In Visual Studio, select the file(s) in Solution Explorer, open the Properties pane, and change the Build Type to "Embedded Resource". You can then use the GetManifestResourceStream method to get a Stream containing the XSLT(s). The name to pass will be based on the default namespace of your assembly, the folder containing the file, and the name of the file.
For example, say your data layer assembly has a default namespace of My.DataLayer. Within your data layer project you have a folder named Templates which contains a file called Transform.xslt. The code to get your XSLT would look like this:
// There are numerous ways to get a reference to the Assembly ... this way works
// when called from a class that is in your data layer. Have a look also at the
// static methods available on the Assembly class.
System.Reflection.Assembly assembly = (GetType()).Assembly;
System.IO.Stream xsltStream = assembly.GetManifestResourceStream("My.DataLayer.Templates.Transform.xslt");
For more information check out this article on CodeProject.
Obvious question maybe, but still has to be asked, did you include the folder containing the XSLT's in the project itself? Is this a web or forms app?
In VS, it is easy to set the properties of the XSLT files in the project to copy on build, by default they do not.
I may have explained myself poorly.
THe Data layer is a class library that a the presentation layer references.
On building the DataLayer I can get the XSLTs to output to the Bin directory of the DataLayer. However when I build and publish the presentation layer, it correctly grabs the DLL but not the XSLTs