Ask a Question related to ASP.NET Building Controls, Design and Development.
-
dave.dolan #1
Generic Composite control (or any web control)
I'm building a Composite control to reflect on an object and build a widget
for each of it's properties based on a custom set of attributes. I'm trying
to do it as a generic, and it works to render the control, but it won't
actually do anything when I try to access it... and infact, trying to access
it kills the vshost process in the debugging, so something is obviously
really wrong. (I've been all excited here becaue I'm using DynamicMethod to
access the properties and populate the controls, but when I go to access it
is the problem) Is it even possible to do Generic Webcontrols? I'm doing it
like this: (like I said, compiles and renders, just on post back, it kills my
server process)
OnInit()
{
ObjectWidget<AddressObject> addressEditor = new
ObjectWidget<AddressObject>();
addressEditor.ID = "FooBar";
Page.Form.Controls.Add(addressEditor);
}
Button1_OnClick(blah)
{
// tried using findcontrol, but returns null, when I list control types
by enumerating them it actually shows one of the right type, at position 2
so..
//AddressObject ao = (Page.Form.FindControl("FooBar") as
ObjectWidget<AddressObject>).Item;
// yes I know not to do this in real life, I'm just trying to figure
this out
AddressObject ao = (Page.Form.Controls[2] as
ObjectWidget<AddressObject>).Item;
// the Item property is of Type T, in this case AddressObject
// test
Response.Write(ao.Street + "<br/>");
Response.Write(ao.City + "<br/>");
}
Am I barking up the wrong tree? I can refactor it to take a property that
contains a System.Type but I'd also have to have a method of it that returns
a System.Object to access the internal value, which if you ask me is pretty
yuk.
dave.dolan Guest
-
Losing Composite Control property that another Composite Control ...
Hi, I'm creating 2 composite controls in ASP.net. Control 1 is a Search control and control 2 is a Map control. I have added a property... -
Implementing Control Designer Class for Composite Server Control
I created a custom composite server control with 2 literals and 1 text box. The control displays fine in internet explorer, but doesnt display... -
Possible to create a composite control that has a child control that is a validator that validates the composite control itself?
I am attempting to create a composite control which has a label, followed by an optional error message, followed by two text boxes. I have... -
Composite control delegating databound templated features to child <asp:repeater> control
Hi Everybody, I'm creating a composite control in C# that basically renders a bunch of webcontrols such as <asp:Label />, <asp:Repeater />,... -
Using Table control in a custom composite control. Control does not render properly in design time.
All, I have written a very simple custom composite control that includes a control of type System.Web.UI.WebControls.Table. The control...



Reply With Quote

