How to use CssStyleCollection for UserControl?

I want to do custom CSS style rendering, so I created a new UserControl.

From there, I thought it was easy to create a new CssStyleCollection called Style. This does not work! How to compile this code? (just an example)

class MyControl : UserControl{
  CssStyleCollection Style=new CssStyleCollection(); //compiler error on the `new..` 
}

I do not understand what I am doing wrong here. CssStyleCollection is a private class, but it is not static. How to create a new instance?

In addition, the specified compiler error

The type System.Web.UI.CssStyleCollection has undefined constructors

+3
source share
2 answers

CssStyleCollection Style; Style GetStyleAttributes, CssStyleCollection, Style, , , CssStyleCollection. , IUrlResolutionService, .

+4

, - .Net , ... . http://bart-at-work.blogspot.com/2008/11/create-cssstylecollection-instance.html

, , CssStyleCollection , , .

CssStyleCollection Style=new Panel().Style;

, "", .Net Mono, .

+1

Source: https://habr.com/ru/post/1727825/


All Articles