开发者

Programmatic accessing a control from base to derived?

In a recent post, I expressed a need to access the properties for the body using declarative syntax, see

Contentplaceholder for replacing attributes?

I thought the first suggestion solved my problem. But, the syntax confuses the editor which is not acceptable.

My hypothesis for a workable solution is to make the change in code. To derive a class from System.Web.UI.Page with extended functionality. However, I want for the designer to be able to still use declarative syntax to set the body tag.

In other words,

  1. I do not want to have to change any code in my aspx web pages except that they derive from base

  2. I want to be able to set these properties using declarative syntax, merely by adding a tag in the derived page

I'm not immediately sure how to go about doing this because it doesn't exactly fit the OOP paradigm and I'm not sure where the changes ne开发者_如何学Ced to be made.

Initial hypothesis,

I can use a findcontrol in the base to see if the placeholder has been added. But, not sure exactly at what point in the page processing lifecycle that I can use this findcontrol. I need to set the body before it renders but also be able to grab something from the declarative code.

I hope what I'm trying to accomplish is clear(?) Basically, I want to be able to edit a user defined tag in my aspx page that will change the class for the body in a master page.


Why not create a custom server control (called something like BodyAttributeManager) that does not render anything, but just looks at its attributes and programatically adds them to the body element on PreRender?


Nested tags as mentioned in that example isn't going to work. ASP.NET does not support that. @jball's suggestion is a good idea; having a class outside of the body that can programmably affect the body's settings from code (which is the only real solution here) would give you what you are looking for.

HTH.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜