How do I get my custom web component's Absolute Position information from the VS.Net 2003 Designer?
-
I was just about finishing creating my own custom web/server-side combobox component, when I noticed that the component was acting strangely in absolute positioning mode. I could position it in the VS.Net 2003 Designer, but further left I positioned the component, the wider it got. Looking at html view in the designer I can see that the positioning information is written to the inline style string of my custom component, but from within the class code, if I try to read it from MyBase, I don't see this information. I originally tried to shadow the Style property, but for some reason Microsoft set it up so you could only read the property. Writing to it caused an error saying that you can only update the Style at runtime. To get around this I created my own ComponentStyle property, which allowed me to read and write the style information to a span webcontrol object. In this property, I can get or set the span's Style property. This appeared to work until I noticed the problem I spoke about above. Which is caused because VS.NET Designer creates its own style in my custom componet. I wouldn't mind using that one except that it displays System.Web.UI.CssStyleCollection in the Designer property window for Style, and the user can't do anything with it. Also I found using my own ComponentStyle property that I need to standardize the user settings when they are added or removed from the style collection or else there can be a WIDTH, a Width, and a width, as the collection isn't smart enough to know that they are all the same. I tried creating a Setter for a shadowed version of the Style so I could update my ComponentStyle property when the Designer updates the Style property, but then my component doesn't render in the designer. How do I get the Designer to use my ComponentStyle property or "catch" the changes in the Style that the Designer creates?
-
I was just about finishing creating my own custom web/server-side combobox component, when I noticed that the component was acting strangely in absolute positioning mode. I could position it in the VS.Net 2003 Designer, but further left I positioned the component, the wider it got. Looking at html view in the designer I can see that the positioning information is written to the inline style string of my custom component, but from within the class code, if I try to read it from MyBase, I don't see this information. I originally tried to shadow the Style property, but for some reason Microsoft set it up so you could only read the property. Writing to it caused an error saying that you can only update the Style at runtime. To get around this I created my own ComponentStyle property, which allowed me to read and write the style information to a span webcontrol object. In this property, I can get or set the span's Style property. This appeared to work until I noticed the problem I spoke about above. Which is caused because VS.NET Designer creates its own style in my custom componet. I wouldn't mind using that one except that it displays System.Web.UI.CssStyleCollection in the Designer property window for Style, and the user can't do anything with it. Also I found using my own ComponentStyle property that I need to standardize the user settings when they are added or removed from the style collection or else there can be a WIDTH, a Width, and a width, as the collection isn't smart enough to know that they are all the same. I tried creating a Setter for a shadowed version of the Style so I could update my ComponentStyle property when the Designer updates the Style property, but then my component doesn't render in the designer. How do I get the Designer to use my ComponentStyle property or "catch" the changes in the Style that the Designer creates?
Using Me.Behavior.GetStyleAttribute( Key ), where Key is one of the Style attributes such as Position, Left, Top, etc., seems to get the modified Style information. Behavior in this case gets the DHTML properties. So now that I can get this information and send them back to the appropriate property in my component, I need to prevent the Designer from writing out the style string. How can I do this? If I let the designer write the style string out to my component's HTML, then it acts as if it is nested inside of another absolute positioned container, throwing the design time position way off! Also, it's confusing to the people using my component to have a ComponentStyle and a Style. FYI: the reason I'm using a ComponentStyle rather than just style is that you can't create a fully read/write override/shadow property for Style, as style is read only, and will give you an error saying that you may only update it at runtime. Darn, Microsoft thought of Everything!