在Asp.net页面生命周期中更改任何控件样式的最佳方法是什么? [英] What is the best Method to change styles of any control in Asp.net Page Life Cycle?

查看:70
本文介绍了在Asp.net页面生命周期中更改任何控件样式的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Asp.net页面生命周期中更改任何控件样式的最佳方法是什么?





在采访中他们问道以上问题....我不知道怎么理解这个问题PLZ帮助我,如果有人知道...

What is the best Method to change styles of any control in Asp.net Page Life Cycle?


In interview they asked above question.... I don't know how should i understand this question plz help me if any one know...

推荐答案

我想,它是Pre -Render方法,我们改变控件的样式。



你可以通过这个链接

http://www.techrepublic.com/blog/software-engineer/aspnet-basics-the-page -life-cycle / [ ^ ]
I suppose, It is Pre-Render Method where we change the styling of the controls.

You can go through this link
http://www.techrepublic.com/blog/software-engineer/aspnet-basics-the-page-life-cycle/[^]


webcontrol的ApplyStyle方法是最好的方法将指定样式的任何非空白元素复制到Web控件,覆盖任何现有的样式元素控制。此方法主要由控件开发人员使用。



system.web.ui.webcontrols.webcontrol.applystyle(v = vs.100).aspx [ ^ ]
ApplyStyle method for webcontrol is a best method Copies any nonblank elements of the specified style to the Web control, overwriting any existing style elements of the control. This method is primarily used by control developers.

system.web.ui.webcontrols.webcontrol.applystyle(v=vs.100).aspx[^]


解决方案



答案是 HTMLTextWriter.AddStyleAttribute方法 [ ^ ]。

Solution

The answer is HtmlTextWriter.AddStyleAttribute Method[^].
Quote:

将标记样式属性添加到元素的开始标记中 HtmlTextWriter 对象随后调用 RenderBeginTag 方法。

Adds a markup style attribute to the opening tag of the element that the HtmlTextWriter object creates with a subsequent call to the RenderBeginTag method.



例子



1. HTMLTextWriter和Controls [ ^ ]

2. 使用HtmlTextWriter类在VB.NET中渲染自定义控件 [ ^ ]


这篇关于在Asp.net页面生命周期中更改任何控件样式的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆