Last post Jun 25, 2008 04:13 PM by awilinsk
Jun 25, 2008 03:39 PM|stevescotthome|LINK
In my custom control I made a Text property to expose a label
And in the class definition I put
Now should that not let me access source.text in my client
Jun 25, 2008 03:44 PM|awilinsk|LINK
Jun 25, 2008 03:51 PM|stevescotthome|LINK
Ahhh...I figured since it didnt have a type it just inherited whatever the object had/has.
Still returning undefined though
Jun 25, 2008 04:01 PM|awilinsk|LINK
Its showing as undefined because there is no <input type="text" /> with that id. When you put a validator on your custom control, it's taking the custom controls ID which is not the same as the TextBox inside the custom control. It looks like you are trying
to create a custom drop down list or something. I would inherit from TextBox and then override its render method to make your drop down list (or whatever). This way the <input type="text" /> will have the same clientID as your custom control. You could also
try overriding the ClientID of the custom control and returning the TextBox's ClientID.
Jun 25, 2008 04:06 PM|stevescotthome|LINK
Ooooh, so when it renders, everything inside my custom control gets thrown onto the page "ungrouped" from their parent control then?
Jun 25, 2008 04:13 PM|awilinsk|LINK
If you go with the first method of deriving from TextBox then the server will not know about anything else besides the TextBox, becuase you would just be telling the HtmlTextWriter to just send this HTML to the page along with the actual TextBox rendering
(which is <input type="text" />) which is what I would do if you don't need any other Server Controls (ie a Button, ListBox and not a <div>).
I would personally choose the first method.