I'm having an issue trying to create my first .Net User Control with Umbraco.
I'm following the hello world tutorial video on the umbraco site but I seem to get errors while doing so. I'm using visual web developer 2010 express edition.
I run into problems when I copy the .dll File from my VWD 2010 into the Umbraco bin folder, I get an error telling me:
Could not load file or assembly 'HelloWorld' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
If dont copy the .dll file and continue with the tutorial and make the macro and use it in the master page the following appears instead of hello world:
Error creating control (usercontrols/HelloWorld.ascx). Maybe file doesn't exists or the usercontrol has a cache directive, which is not allowed! See the tracestack for more information!
Also I'm not sure if this is relevant but when I open the Umbraco user controls folder and open my helloworld user control it looks like:
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="HelloWorld.ascx.vb" Inherits="HelloWorld.HelloWorld" %> Hello World!
The CodeBehind="HelloWorld.ascx.vb" is underlined in green and when I mouse over it, it says file HelloWorld.ascx.vb was not found.
Are you referencing the correct umbraco dll files in your project? (should be the ones from the bin folder, in which you copy your user control bin to)
Do you remember to copy .aspx file into the usercontrol folder?
The fact that the HelloWorld.ascx.vb code-behind file can't be found (what happens if you hit F7 with the ascx file open?) most likely indicates that you have modified some values like the file name yourself. Best idea to resolve it is to delete the whole thing and start with a fresh ascx control, VS should take care of the rest.
As to your initial problem: it looks like you have build your custom control using another (newer) framework like the one you are currently running Umbraco with. Can you please check in IIS which framework you are using with your Umbraco install? In your VWD 2010 project go to properties and look up for which framework it will be compiled. My guess is that you have used framework 4.0 for your custom project and are running Umbraco in 3.5, but that's just a guess.
Thank you for your reply. I have checked which framework im using with VWD and you are right its 4.0. I opened IIS to try see what framework im using with umbraco but can't figure out how to do this (I'm in over my head). If I am running 3.5 can it be changed to 4? or do i have to re-install umbraco again? I'm fairly new to web and umbraco so sorry if my questions are nooby.
In IIS you need to go to the application pool - here you can double click on the application pool your site is using and you can change the framework.
However this will probably not work since you're probably using the web.config for .NET 3.5 - But I think you should be able to get the .NET 4 version from codeplex and use that instead. Of course you'll need to enter connection string details etc. - I think that is all it takes.
You should also be able to determine the .NET version by looking in your web.config file. If you go to the <compilation> element you can see the value of the targetFramework attribute. If it says 3.5 you're running .NET 3.5 if it says 4.0 you're running .NET4.
Thanks for the help, I changed the framework with your instructions and you were right it still didn't work (I get a server error in umbraco). Im trying to get the web.config for .net 4 but cant seem to find it? once I get this things should work? Im feeling lost in all this
But I'm not sure if that's all it takes. I have never switched from one version to another...so my approach is a bit trial'n'error like.
But maybe it's possible for you to simply just compile against the .NET 3.5 framework instead? That seems to be the most pragmatic solution to me. But I bet Sascha can guide you better on this than I can, in case the above suggestions does not work.
Thanks for the link, unfortuneatly for me it wasn't straight forward copy and paste with a change to the connection string details. This stuff seems so complicated for me, I've went from a tutorial to mental stuff haha, but thank you for your help its much appreciated. I'm just wondering would there be a simpler way of doing things? i.e installing umbraco again or something because I seem to be getting lost in this version/framework stuff. I'm also unsure of what you mean when you say "But maybe it's possible for you to simply just compile against the .NET 3.5 framework instead"
I agree that it can be a bit overwhelming when you come to this all for the first time, especially since there are now quite a couple of variants out there, which - although a good amount of work has been spent on making things consistent and backwards compatible - have all their little quirks and switching between versions (especially when ASP.Net is concerned) requires above all a good deal of experience to not end up in a good deal of pain. :)
However, there is always the straightforward approach. In my opinion if you realize that something's not right on a basic level it's most of the time easier to start from scratch again (obviously only if you're not too far in development; and even then I prefer manually transferring 10 user controls to a newly created project than manically trying to find out what went wrong somewhere along the road with the project). In your case you can easily do the following:
Create a new project. In the new project dialogue you will see at the top of the popup window (I think it's the top, might also be at the bottom) a dropdown where you can select the .Net framework you wish to target. By default this will be 4.0. If you change this to 3.5 you will get a couple less options of types of projects (after all, you won't be able to use the 4.0 stuff if you are compiling against 3.5, yet that should not worry you at all at the moment), select the ascx user control as you did before.
Another way to do this with an existing project is go to properties and select another framework there.
As to the framework used with your Umbraco install: It might be that 4.0 is not available where you've installed it (or you specifically downloaded the 3.5 installer, which I doubt you did), so it's set up for 3.5. Honestly, I don't think it will make a difference for you at the moment if you are using 3.5 or 4.0 and I wouldn't worry too much about that now. If you definitely want to get it running in 4.0 then I'd first make sure if 4.0 is installed properly. Which OS are you running Umbraco on?
Hi I am new in umbraco CMS .net controler. I am just wondering any one cal help me to create a customize Contact form by Web User control. I follow thw whole tutorial. But the problem is when i add valodation contron on my form. Then i found this erroe message...
The ControlToValidate property of 'RequiredFieldValidator1' cannot be blank. and more ......
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ContactUsForm.ascx.cs" Inherits="ContactUsForm.ContactUsForm" %>
I GOT A BIG SAME PROBLEM TO RESOLVE - SOMEBODY HELP ME
First, sorry for my english 'cos I'm Brazilian, well, my problem is...
My template structure:
HOME (FOLDER WIHT BODY TEXT HOME CONTENT)
|__ Quem somos (subpage with body text content)
|__ Contatos (subpage with body text content)
|__ Noticias (subpage with body text content)
I have a form.ascx in the usercontrols folder and form.ascx.cs in the App_code, up to here ok.
I load this macro without problem in my subpages template (quem somos | contatos | noticias | ...) but in the Home page the componets stop the read code when the code read some like asp:textbox then shows anything more about the form.ascx.
.Net User Control
Hi Sorry If I post this under the wrong section.
I'm having an issue trying to create my first .Net User Control with Umbraco.
I'm following the hello world tutorial video on the umbraco site but I seem to get errors while doing so. I'm using visual web developer 2010 express edition.
I run into problems when I copy the .dll File from my VWD 2010 into the Umbraco bin folder, I get an error telling me:
Could not load file or assembly 'HelloWorld' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
If dont copy the .dll file and continue with the tutorial and make the macro and use it in the master page the following appears instead of hello world:
Error creating control (usercontrols/HelloWorld.ascx).
Maybe file doesn't exists or the usercontrol has a cache directive, which is not allowed! See the tracestack for more information!
Also I'm not sure if this is relevant but when I open the Umbraco user controls folder and open my helloworld user control it looks like:
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="HelloWorld.ascx.vb" Inherits="HelloWorld.HelloWorld" %>
Hello World!
The CodeBehind="HelloWorld.ascx.vb" is underlined in green and when I mouse over it, it says file HelloWorld.ascx.vb was not found.
Anybody got any ideas?
Hi Stephen
A few things to check
/Jan
Hi Jan,
Thanks for the reply, I have checked those points but still getting the same errors. I'll do it again to make sure I'm not forgetting anything.
Hi stephen,
The fact that the HelloWorld.ascx.vb code-behind file can't be found (what happens if you hit F7 with the ascx file open?) most likely indicates that you have modified some values like the file name yourself. Best idea to resolve it is to delete the whole thing and start with a fresh ascx control, VS should take care of the rest.
As to your initial problem: it looks like you have build your custom control using another (newer) framework like the one you are currently running Umbraco with. Can you please check in IIS which framework you are using with your Umbraco install? In your VWD 2010 project go to properties and look up for which framework it will be compiled. My guess is that you have used framework 4.0 for your custom project and are running Umbraco in 3.5, but that's just a guess.
Hope that helps,
Sascha
Hi Sascha,
Thank you for your reply. I have checked which framework im using with VWD and you are right its 4.0. I opened IIS to try see what framework im using with umbraco but can't figure out how to do this (I'm in over my head). If I am running 3.5 can it be changed to 4? or do i have to re-install umbraco again? I'm fairly new to web and umbraco so sorry if my questions are nooby.
Thanks
Steve
Hi Stephen
In IIS you need to go to the application pool - here you can double click on the application pool your site is using and you can change the framework.
However this will probably not work since you're probably using the web.config for .NET 3.5 - But I think you should be able to get the .NET 4 version from codeplex and use that instead. Of course you'll need to enter connection string details etc. - I think that is all it takes.
You should also be able to determine the .NET version by looking in your web.config file. If you go to the <compilation> element you can see the value of the targetFramework attribute. If it says 3.5 you're running .NET 3.5 if it says 4.0 you're running .NET4.
Hope this helps.
/Jan
Hi Jan,
Thanks for the help, I changed the framework with your instructions and you were right it still didn't work (I get a server error in umbraco). Im trying to get the web.config for .net 4 but cant seem to find it? once I get this things should work? Im feeling lost in all this
Thanks
Hi Stephen
I think you should be able to get the .NET 4 web.config from the 4.5.2 version for .NET4, which you can find here on codeplex: http://umbraco.codeplex.com/releases/view/51165
But I'm not sure if that's all it takes. I have never switched from one version to another...so my approach is a bit trial'n'error like.
But maybe it's possible for you to simply just compile against the .NET 3.5 framework instead? That seems to be the most pragmatic solution to me. But I bet Sascha can guide you better on this than I can, in case the above suggestions does not work.
/Jan
Hi Jan,
Thanks for the link, unfortuneatly for me it wasn't straight forward copy and paste with a change to the connection string details. This stuff seems so complicated for me, I've went from a tutorial to mental stuff haha, but thank you for your help its much appreciated. I'm just wondering would there be a simpler way of doing things? i.e installing umbraco again or something because I seem to be getting lost in this version/framework stuff. I'm also unsure of what you mean when you say "But maybe it's possible for you to simply just compile against the .NET 3.5 framework instead"
Once again thanks for the help
Hi stephen,
I agree that it can be a bit overwhelming when you come to this all for the first time, especially since there are now quite a couple of variants out there, which - although a good amount of work has been spent on making things consistent and backwards compatible - have all their little quirks and switching between versions (especially when ASP.Net is concerned) requires above all a good deal of experience to not end up in a good deal of pain. :)
However, there is always the straightforward approach. In my opinion if you realize that something's not right on a basic level it's most of the time easier to start from scratch again (obviously only if you're not too far in development; and even then I prefer manually transferring 10 user controls to a newly created project than manically trying to find out what went wrong somewhere along the road with the project). In your case you can easily do the following:
Create a new project. In the new project dialogue you will see at the top of the popup window (I think it's the top, might also be at the bottom) a dropdown where you can select the .Net framework you wish to target. By default this will be 4.0. If you change this to 3.5 you will get a couple less options of types of projects (after all, you won't be able to use the 4.0 stuff if you are compiling against 3.5, yet that should not worry you at all at the moment), select the ascx user control as you did before.
Another way to do this with an existing project is go to properties and select another framework there.
As to the framework used with your Umbraco install: It might be that 4.0 is not available where you've installed it (or you specifically downloaded the 3.5 installer, which I doubt you did), so it's set up for 3.5. Honestly, I don't think it will make a difference for you at the moment if you are using 3.5 or 4.0 and I wouldn't worry too much about that now. If you definitely want to get it running in 4.0 then I'd first make sure if 4.0 is installed properly. Which OS are you running Umbraco on?
Hope that helps,
Sascha
Thanks for the help Sascha,
I'll try your suggestion on Monday when I get home. Im running Umbraco on windows 7 and installed it using the Microsft Web Platform Installer.
Cheers.
Hey guys,
Compiling with .NET 3.5 solved my issue thanks for the help
Steve
Cool, glad you got it working now. :)
Hi I am new in umbraco CMS .net controler. I am just wondering any one cal help me to create a customize Contact form by Web User control. I follow thw whole tutorial. But the problem is when i add valodation contron on my form. Then i found this erroe message...
The ControlToValidate property of 'RequiredFieldValidator1' cannot be blank. and more ......
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ContactUsForm.ascx.cs" Inherits="ContactUsForm.ContactUsForm" %>
<form action="" method="post" name="contactus">
<table width="672" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="292"><input type="text" name="fname" id="fname" value="First Name"/><asp:RequiredFieldValidator
ID="RequiredFieldValidator1" runat="server"
ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
</td>
<td width="380" rowspan="6" valign="top"><table width="380" border="0" cellspacing="0" cellpadding="0" id="contact2">
<tr>
<td colspan="2"><textarea name="txtcomments" id="txtcomments" cols="45" rows="5">Enter text...</textarea></td>
</tr>
<tr>
<td width="187"><input name="Captcha" type="text" class="captcha" id="sml-input" value="78 BHG" /></td>
<td width="193"><span id="accessiblity">Ut et metus dapibus dolrutrum vestibulum molestie id ligula.</span></td>
</tr>
<tr>
<td colspan="2"><input name="sml-input" type="text" id="sml-input" value="Enter Code" /></td>
</tr>
<tr>
<td colspan="2"><a class="button" type="submit" href="#">Send Enquiry</a></td>
</tr>
</table></td>
</tr>
<tr>
<td><input name="fname" type="text" id="lname" value="Last Name" /></td>
</tr>
<tr>
<td><input name="company" type="text" id="company" value="Company Name" /></td>
</tr>
<tr>
<td><input name="emailaddress" type="text" id="emailaddress" value="Email address" /></td>
</tr>
<tr>
<td><select name="country" id="country">
<option>Please select your country</option>
</select></td>
</tr>
<tr>
<td><label>
<input type="checkbox" name="chkmail" id="chkmail" />
I would like to receive relevant insight, news and reports from ICLP</label></td>
</tr>
</table>
</form>
Please give me an idea or anything else. Thank you.......
I GOT A BIG SAME PROBLEM TO RESOLVE - SOMEBODY HELP ME
First, sorry for my english 'cos I'm Brazilian, well, my problem is...
My template structure:
HOME (FOLDER WIHT BODY TEXT HOME CONTENT)
|__ Quem somos (subpage with body text content)
|__ Contatos (subpage with body text content)
|__ Noticias (subpage with body text content)
I have a form.ascx in the usercontrols folder and form.ascx.cs in the App_code, up to here ok.
I load this macro without problem in my subpages template (quem somos | contatos | noticias | ...) but in the Home page the componets stop the read code when the code read some like asp:textbox then shows anything more about the form.ascx.
Can somebody help me?
Resolved: FAIL myself, I forgot to insert <form ...> tag in my Masterpage.
is working on a reply...