What's the equivalent to #include
-
What's the equivalent to using #include files in ASP.NET?
The reason I want to use include files is because I want to maintain a template on all .aspx pages so that if my boss wants to change the look of the company page, I wouldn't need to change every single page. I would have files like _top.inc and _bottom.inc. Right now, my guess is that you can only use user controls, but I don't this method would allow me to enclose the main page in a and tag.:~ Frank http://www.frankliao.com
-
What's the equivalent to using #include files in ASP.NET?
The reason I want to use include files is because I want to maintain a template on all .aspx pages so that if my boss wants to change the look of the company page, I wouldn't need to change every single page. I would have files like _top.inc and _bottom.inc. Right now, my guess is that you can only use user controls, but I don't this method would allow me to enclose the main page in a and tag.:~ Frank http://www.frankliao.com
Frank Liao wrote: The reason I want to use include files is because I want to maintain a template on all .aspx pages so that if my boss wants to change the look of the company page, I wouldn't need to change every single page. I would have files like _top.inc and _bottom.inc Yes you can use User Controls/Custom Controls/Etc. Controls (even with the TD problem you mentioned) but it is probably better to use proper page inheritance, templating in ASP.NET. About the only reason I see for using include files anymore is if you are porting a lot of ASP over to ASP.NET. Other than that, probably best to avoid.
Paul Watson
Bluegrass
Cape Town, South AfricaRay Cassick wrote: Well I am not female, not gay and I am not Paul Watson
-
Frank Liao wrote: The reason I want to use include files is because I want to maintain a template on all .aspx pages so that if my boss wants to change the look of the company page, I wouldn't need to change every single page. I would have files like _top.inc and _bottom.inc Yes you can use User Controls/Custom Controls/Etc. Controls (even with the TD problem you mentioned) but it is probably better to use proper page inheritance, templating in ASP.NET. About the only reason I see for using include files anymore is if you are porting a lot of ASP over to ASP.NET. Other than that, probably best to avoid.
Paul Watson
Bluegrass
Cape Town, South AfricaRay Cassick wrote: Well I am not female, not gay and I am not Paul Watson
Paul Watson wrote: Yes you can use User Controls/Custom Controls/Etc. Controls (even with the TD problem you mentioned) but it is probably better to use proper page inheritance, templating in ASP.NET. Templating perhaps, inheritance not, I struggled with that for days and can confirm (by looking at the output html) that there are some "serious" flaws in that approach. See a post of mine about a week back of how I think you should do it. http://www.codeproject.com/script/comments/forums.asp?msg=315584&forumid=12076&mode=all&userid=38829#xx315584xx[^]. I can honestly say my way is a much better approach and "more" inline with the ASP.NET way. Cheers :) PS: Happy B-day for yesterday ;) "There are no stupid question's, just stupid people."
-
Paul Watson wrote: Yes you can use User Controls/Custom Controls/Etc. Controls (even with the TD problem you mentioned) but it is probably better to use proper page inheritance, templating in ASP.NET. Templating perhaps, inheritance not, I struggled with that for days and can confirm (by looking at the output html) that there are some "serious" flaws in that approach. See a post of mine about a week back of how I think you should do it. http://www.codeproject.com/script/comments/forums.asp?msg=315584&forumid=12076&mode=all&userid=38829#xx315584xx[^]. I can honestly say my way is a much better approach and "more" inline with the ASP.NET way. Cheers :) PS: Happy B-day for yesterday ;) "There are no stupid question's, just stupid people."
leppie wrote: that there are some "serious" flaws in that approach. How so? I had a look at your post below, but what is different with your approach to the other articles approach?
Paul Watson
Bluegrass
Cape Town, South AfricaRay Cassick wrote: Well I am not female, not gay and I am not Paul Watson
-
leppie wrote: that there are some "serious" flaws in that approach. How so? I had a look at your post below, but what is different with your approach to the other articles approach?
Paul Watson
Bluegrass
Cape Town, South AfricaRay Cassick wrote: Well I am not female, not gay and I am not Paul Watson
By overriding Render() in a page class, you basically remove the "Page" functionality and have to do all the rendering yourself. Also base.Render() should NOT be called as in the article, but like I said Render() is a core function of the Page class and you need that. I you paste his example in a file, and run it you will see that the outputted HTML is wrong, like a page within a page, because of the base.Render() that's being called. Now you can replace base.Render() with RenderChildren() (i think the output will be better), but you have lost 80% of the Page classes functionality by this point, defeating the point of inheritance. My way, I programmtically add controls at page initialization to achieve the inherited effect and keep page functionality. You still however lose designer support. Cheers :) "There are no stupid question's, just stupid people."
-
By overriding Render() in a page class, you basically remove the "Page" functionality and have to do all the rendering yourself. Also base.Render() should NOT be called as in the article, but like I said Render() is a core function of the Page class and you need that. I you paste his example in a file, and run it you will see that the outputted HTML is wrong, like a page within a page, because of the base.Render() that's being called. Now you can replace base.Render() with RenderChildren() (i think the output will be better), but you have lost 80% of the Page classes functionality by this point, defeating the point of inheritance. My way, I programmtically add controls at page initialization to achieve the inherited effect and keep page functionality. You still however lose designer support. Cheers :) "There are no stupid question's, just stupid people."
leppie wrote: My way, I programmtically add controls at page initialization to achieve the inherited effect and keep page functionality. You still however lose designer support. OIC, I thought you were saying the whole ASP.NET inheritance, override thing was flawed. Had me worried for a bit. Overriding the render event is not always needed, but in some cases you have to.
Paul Watson
Bluegrass
Cape Town, South AfricaRay Cassick wrote: Well I am not female, not gay and I am not Paul Watson