ceciltech
 XMod Newcomer Posts: 3

 |
| 9/28/2005 9:18 AM |
|
Hello, I am trying to create a very simple form control that inherits from the standard TextBox class. Eventually this control will encrypt it's data before storing it or sending e-mail, for now it just adds an 's' in front. The controls data is saved with the 's' but when I go to edit the record my control is always empty even though the data is in the record? I have attached the very simple class file. I know this should be very easy could you please tell me what I am doing wrong? DNN 3.1.1 and DNN3_XMod324 Cecil PS If I get it working I will make it freely available. |
Attachment: 192818528171.zip
|
|
|
|
dnndev
 XMod All-Star Posts: 4621
 dnndev.com Broadcasting Live from Somewhere in Arizona
 |
| 9/28/2005 11:56 AM |
|
Hi Cecil, Have you tried this control in a non-XMod context - i.e. on a regular aspx page to ensure it's saving it's data between postbacks? Best, Kelly |
|
Put the power of XMod to work for you today Purchase XMod from Snowcovered |
|
|
ceciltech
 XMod Newcomer Posts: 3

 |
| 9/28/2005 1:46 PM |
|
Kelly, Thank you for the quick reply...but I don't think postbacks are involved here. The control saves fine but when I go to edit an existing record the control comes up empty even though the template shows the data and it is in the table. Since my control was never created for display of the template then postback is not the issue. If you take a moment to look at the very short class file I attached you will see that all I am doing is inheriting from textbox and implementing your IFormControl interface and then overriding the Text property of the Textbox(I also tried with no override of Text, same problem). This is about the simplest control you could possibly create I must be missing something basic or your code has a serious bug. Cecil |
|
|
|
|
dnndev
 XMod All-Star Posts: 4621
 dnndev.com Broadcasting Live from Somewhere in Arizona
 |
| 9/28/2005 3:14 PM |
|
Hi Cecil, I've tracked the issue down. The problem stems from the fact that your control inherits from, rather than encapsulating, the TextBox control. The logic is seeing it as a text box first and processing it as such, preventing it from being processed as a custom control. I'll change the logic to ensure custom form controls directly inherited from server controls are processed appropriately. In the meantime, you can workaround this by not inheriting from the TextBox. Instead, inherit from System.Web.UI.Control or System.Web.UI.WebControls.WebControl. Override CreateChildControls() and in that procedure, add the TextBox to your control's Controls collection. Best, Kelly |
|
Put the power of XMod to work for you today Purchase XMod from Snowcovered |
|
|
ceciltech
 XMod Newcomer Posts: 3

 |
| 9/30/2005 8:35 AM |
|
Kelly, Worked like a charm. Thank you for the quick response! Cecil |
|
|
|
|
timrolands
 XMod Jr. Varsity Posts: 20

 |
| 9/28/2006 4:55 PM |
|
Cecil, we are trying to do something just like this, but we're not having much luck. Glad I found this thread.
Any chance you could post your revised code? I'd like to compare to what we have, because I'm not sure we're implementing Kelly's suggestion correctly.
Thanks! |
|
|
|
|
timrolands
 XMod Jr. Varsity Posts: 20

 |
| 9/29/2006 8:23 AM |
|
Oh, never mind, Cecil. I got it working this morning! Thanks anyway. I will see if I can get permission to share the control. Tim |
|
|
|
|