The only way to create this was to create a .NET User Control; there are two approaches that I am aware of for adding controls to your site which are:
- Open the site in Visual Studio using the File > Open Website option and point to the directory of your Umbraco site (remember there is no solution or project files). From here you can add a new "Web User Control" and the dll and ascx file will be included in the website
- (My chosen route) Create a new ASP.NET Empty Web Application that can be your User Control library that can be used across multiple sites. Then its just a case of copying any .ascx files in to the Umbraco usercontrols folder and the .dll file into the bin folder.
I created my contact form and tested without issue in the stand alone library project however when I came to add the custom control on to my Umbraco page wrapped as a macro no events fired. After closer investigation I realised that my control was not wrapped by a <form> tag and as such was treated as standard HTML controls with not event firing.
The rule of thumb is that every ASP.NET User Control that has the runat="server" attribute must be placed inside a <form> tag that also contains a runat="server" attribute and a unique id. You can either add the form tag within your User Control or on the page within the Umbraco Template.
wow, very helpful article, thanks for sharing mate, i will try it, oh if you looking for umbraco hosting, you can click here
ReplyDeleteit did not work for me....is there any chances of user control in umbraco version 7.0 working? I have created a user control in the umbraco project on UserControls...created a macro by using user control....then called the user control macro in the content of rich text editor.....it was a simple button click and the button click event is not working....
ReplyDelete