N
Nick Stansbury
Hi,
ASP.Net 2 - Strange bug / problem observed with the use of the readonly
property in composite custom controls. Using the class shell defined below,
the issue is with the readonly property. If you set the inner text box's
"ReadOnly" property to be true, and then use javascript (in this case a
pop-up window) to pass back a value into the text box, then the values in
the text box is not persisted accross postbacks. Very bizarre. Not the case
under the old version of Asp.net. However replace Readonly = true with
_textbox.Attributes.Add("ReadOnly", "ReadOnly") then it works fine. Anyone
got any ideas why?
Nick
Here's the class shell (I wrote this off-the-cuff here so I hope all the
code is right - the important thing is the principle!) :
Public Class MyCustomControl : inherits WebControl : implements
iNamingContainer
Private _Textbox as textBox
private Image as Image
Protected Overrides Sub CreateChildControls()
_TextBox = new TextBox
_TextBox.ID = "txtInnerTextBox"
Me.Controls.add(_TextBox)
_Image = new Image
_Image.ID = "imgInnerImage"
Me.Controls.Add(_Image)
_TextBox.Readonly = true
_Image.Attributes.Add("onclick", "Javascript:document.getElementById('"
& Me._TextBox.ClientID & "').value='Hullo');")
End Sub
End Class
ASP.Net 2 - Strange bug / problem observed with the use of the readonly
property in composite custom controls. Using the class shell defined below,
the issue is with the readonly property. If you set the inner text box's
"ReadOnly" property to be true, and then use javascript (in this case a
pop-up window) to pass back a value into the text box, then the values in
the text box is not persisted accross postbacks. Very bizarre. Not the case
under the old version of Asp.net. However replace Readonly = true with
_textbox.Attributes.Add("ReadOnly", "ReadOnly") then it works fine. Anyone
got any ideas why?
Nick
Here's the class shell (I wrote this off-the-cuff here so I hope all the
code is right - the important thing is the principle!) :
Public Class MyCustomControl : inherits WebControl : implements
iNamingContainer
Private _Textbox as textBox
private Image as Image
Protected Overrides Sub CreateChildControls()
_TextBox = new TextBox
_TextBox.ID = "txtInnerTextBox"
Me.Controls.add(_TextBox)
_Image = new Image
_Image.ID = "imgInnerImage"
Me.Controls.Add(_Image)
_TextBox.Readonly = true
_Image.Attributes.Add("onclick", "Javascript:document.getElementById('"
& Me._TextBox.ClientID & "').value='Hullo');")
End Sub
End Class