UserControls in App_Code-directory
-
I took over a project and found usercontrols in the App_Code-directory, now I was wondering, why put them in App_Code and not just anywhere else. The only reason I could find was if it was a base-class and I want other controls to inherit from it. But if it's just a control that let say shows a logo with some text, why would I put that control in App_Code
http://johanmartensson.se - Home of MPEG4Watcher
-
I took over a project and found usercontrols in the App_Code-directory, now I was wondering, why put them in App_Code and not just anywhere else. The only reason I could find was if it was a base-class and I want other controls to inherit from it. But if it's just a control that let say shows a logo with some text, why would I put that control in App_Code
http://johanmartensson.se - Home of MPEG4Watcher
If it's in app code, it must be a control entirely in code, no markup. That would then be where it belongs
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
If it's in app code, it must be a control entirely in code, no markup. That would then be where it belongs
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
So as soon as I'm creating a control that uses hyperlink, textbox and so on, It should not be in App_Code. I found a UserControl with this method in it:
public override void RenderControl(System.Web.UI.HtmlTextWriter writer) { writer.Write(" [" + this.Language[0] + "](\)|[" + this.Language[1] + "](\)|[" + this.Language[2] + "](\) "); }
This feels wrong to me, I would have put it in a normal usercontrol outside App_code and used hyperlinks instead.http://johanmartensson.se - Home of MPEG4Watcher
-
So as soon as I'm creating a control that uses hyperlink, textbox and so on, It should not be in App_Code. I found a UserControl with this method in it:
public override void RenderControl(System.Web.UI.HtmlTextWriter writer) { writer.Write(" [" + this.Language[0] + "](\)|[" + this.Language[1] + "](\)|[" + this.Language[2] + "](\) "); }
This feels wrong to me, I would have put it in a normal usercontrol outside App_code and used hyperlinks instead.http://johanmartensson.se - Home of MPEG4Watcher
If it's code, not a control with an ascx, the App_Code is the only place for it unless you put it in a dll. Otherwise, it's not going to be compiled. If the person who worked on it before made good choices in what to use, is a different question, that much is true.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
If it's code, not a control with an ascx, the App_Code is the only place for it unless you put it in a dll. Otherwise, it's not going to be compiled. If the person who worked on it before made good choices in what to use, is a different question, that much is true.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
So I should only create a usercontrol in App_Code if I have a good reason for it? I just can't figure out what that good reason is...
http://johanmartensson.se - Home of MPEG4Watcher
-
So I should only create a usercontrol in App_Code if I have a good reason for it? I just can't figure out what that good reason is...
http://johanmartensson.se - Home of MPEG4Watcher
I would tend to put them in a dll for reuse, if I wrote any,
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
I would tend to put them in a dll for reuse, if I wrote any,
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
Absolutely, I would do that to if I were to reuse them. Could the be any benefits like loading-speed or something if I put the usercontrols in app_code rather than outside?
http://johanmartensson.se - Home of MPEG4Watcher
-
Absolutely, I would do that to if I were to reuse them. Could the be any benefits like loading-speed or something if I put the usercontrols in app_code rather than outside?
http://johanmartensson.se - Home of MPEG4Watcher
None I can think of. They only get loaded the first time a page gets accessed, then they live in server memory
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
None I can think of. They only get loaded the first time a page gets accessed, then they live in server memory
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
Yeah, that's what I thought, I just keep the usercontrols out of app_code until I find a good reason to to otherwise. Thanks Christian...
http://johanmartensson.se - Home of MPEG4Watcher