Developer forum

Forum » Development » User control in Template extender

User control in Template extender

Dmitrij Jazel
Reply

Hi Guys,

I have a question here.

Could you please tell me what do I have to do if I have a user control here.

Maybe some examples, or links would be much appreciated :-)

How do I add it to my Template extender. Since Template extender relies on @tags mainly.

Any idea how to add it and use it?

 

Thanks alot for help!

Dmitrij


Replies

 
Nicolai Høeg Pedersen
Reply

Hi Dmitrij

You cannot have a usercontrol in a template extender.

 

You can though, create a template tag with you extender that returns the string that loads the control later in the process:

 

<!--@ LoadControl(MyControl.ascx)-->

 

But it does not make much sense, since you can just add the same line of code into the tempalte directly.

 

BR Nicolai

 
Dmitrij Jazel
Reply

Hej Nicolai,

Well that sounds easy enough, that's great news, thanks alot for quick response! :-)

Kind regards,

Dmitrij

 
Dmitrij Jazel
Reply

Hej Nicolaj,

Just have a question, where should I locate the user control, if I choose to go the the "...since you can just add the same line of code into the tempalte directly" - way, should I put .ascx file in the Design template folder right next to the template file?

Regards,

Dmitrij

 
Morten Bengtson
Reply
This post has been marked as an answer

Hi Dmitrij,

 

You can pretty much place the control anywhere you want to. If you want to place the control in the same folder as your layout templates then you just add the path, like this...

<!--@LoadControl(/Files/Templates/Designs/MyDesign/MyControl.ascx)-->

 

Details about how you can include user controls can be found in this article by Imar Spaanjaars: 

http://devierkoeden.com/articles/custom-functionality-using-user-controls.aspx

 

Votes for this answer: 1
 
Dmitrij Jazel
Reply

That's perfect, thanks Morten :)

 

You must be logged in to post in the forum