2

I am getting started with umbraco 4.5.2.
I have my site up and running, and I am designing templates using some ASP.NET controls. How can I respond to events from these controls?

For example, I have added a Button to a template. How can I edit the code-behind file to perform some action whenever the button is clicked?

Thank you,

Martin Wiboe

3 Answers 3

5

You can actually create fully functional ASP.NET .ascx Controls, and wrap them in a Macro to display inside your template/page.

Check out this excellent video on how to do this.

Good luck!

Marko

Sign up to request clarification or add additional context in comments.

Comments

0

Have a look at the bottom of this blog post.

Quote:

When using Visual Studio, it’s nice to have code-behind files for your templates (at least, that’s how we do stuff). If you create a template in Umbraco, it creates a masterpage without code-behind…

Then you would have to add a code-behind manually, link it with the mark-up and create designer file. That sucks right?

Just do this:

  1. Create a nested masterpage in VS and use your ‘master’-masterpage as masterpage in the masterpages folder. Lol, there’s a lot of ‘masterpage’ in that sentence hehe. VS creates a masterpage for you with code-behind, sweet!
  2. VS opens the mark-up of this newly created masterpage, keep it opened!
  3. Then go to your Umbraco back-end and create a template like you would normally do.
  4. Give it the same name as you defined in step 1.
  5. This should create an Umbraco template by using the already created masterpage as file.
  6. Now return to Visual Studio. It should notify you that the file has changed and gives you the option to reload the file. Reload and then use CTRL+Z to undo the changes made by Umbraco (else the code-behind won’t be linked to the mark-up) and save it.
  7. You’re done!

2 Comments

Link is dead, please post something that explains the answer.
@MarcUberstein Updated link and quoted the blog post just in case it changes again.
0

There is also this utility that will create the codefiles for you http://umbracocs.codeplex.com/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.