Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Registering .ascx ASP.NET User control in ASP.NET Page or Master Page will load it or not?

If I register user control in ASP.NET page, the control will be loaded to the page or not?
<%@ Register Src=".." TagName="tag" TagPrefix="pre" %>
even if I not call it in the page using?
<pre:tag id='control123' />

because part of my code is executed even if I'm not calling the control, I found that when I did performance profilling.

like image 912
Owidat Avatar asked Jan 30 '12 11:01

Owidat


1 Answers

In this case your user control will be loaded to the page object in server side, that mean it will be processed with whole lifecycle of ASP.NET app, but because you don't create control instance non output html will be rendered. You are using 'type' but not the 'instance'.

Answering you question: yes, it will be loaded, but not rendered, databounded, etc...

Edited 2/7/2012

If you want to get rid of the Register Directive, you always could use web.config - follow instructions of this Scottgu post.

like image 58
Rafał Warzycha Avatar answered Oct 24 '22 02:10

Rafał Warzycha