>>>>When I drag this control onto a web form, all I get is a simple block that looks like a button control and given the label of its base... ie: MyTextbox1
>>>>
>>>>How do I get .net to show me the visual designer of the class as I have it on my webform. I can't even move it to an absolute position on the form, it always appears relative to another control.
>>>>
>>>>At run-time, the proper control shows and functions as I would otherwise expect.
>>>>
>>>>Thanks
>>>
>>>For absolute position you should be in absolute positioning (default is flow layout-which is the recommended one, formerly it was absolute as I remember).
>>>Cetin
>>
>>Don,
>>
>>The answer to your first question is that this is the nature of a WebUserControl (ascx). If you want to see the fully rendered control in the designer, you must create a CustomControl. Unfortunately, there is no designer for a custom control so it has to be done purely in code.
>>
>>This may be a daunting task if you have recently arrived from the VFP world. It may be best to stick with the WebUserControl until you have absorbed a good amount of the inner workings of ASP.NET.
>
>
>ok.. So, now I go to Add Item, then pick "Web Custom Control" from the templates... ex: MyLabel and it comes back with MyLabel.cs ... I take the defaults, and change the default derivation of web controls and change to that of a label, save and compile (strip out the get/set declaration of text since that is a default of the label control anyhow). All ok. Now, I drag/drop that onto a web form and I get
>
>
http://localhost/mytest/mylabel.cs>
>and not a label control itself... Am I missing something stupid??
Don,
Yes, there's a little more to it than that. You have to first override the Render method to emit the proper HTML. In the case of a label it is pretty simple. HTML encode and write the value of the text property to the Output stream which is a property of the ..EventArgs parameter.
It gets more complex when you get to controls that have events that you want to bubble up or when you want to add/modify the properties that are exposed to the designer. Also, if you want to create a control that can be DataBound, you have to create a separate control designer class to tell the IDE how to handle interactive design events and how to properly use a dropdownlist in the properties pane for properties like the DataSource.
A CustomControl has to handle being instantiated within the IDE in addition to being instantiated in the application.