Saturday, March 10, 2012

User Control public properties causes exception on page.

I'm having the same. Did you manage to solve this?

Edmund


I'm running into the same problem.http://ajax.asp.net/docs/tutorials/UsingUpdatePanelUserControls.aspx says you can use UpdatePanels in user controls, but the example doesn't try to set any attributes of controls within the UpdatePanel. Is it because the UpdatePanel is a NamingContainer?


Try this solution it worked for me:

Create a private variable to temporarily store the value of the property. Override the render method of the user control to assign the property to the textbox.

Private _maxLengthAsInteger

PublicProperty MaxLength()AsInteger
Get
Return txtValue.MaxLength
EndGet
Set(ByVal valueAsInteger)
_maxLength = value
End Set
EndPropertyOverridesSub Render(ByVal writerAs System.Web.UI.HtmlTextWriter)
txtValue.MaxLength = _maxLength
MyBase.Render(writer)
EndSub

Good luck, Hanan Schwartzberg
--------
Custom programming and web design
http://www.lionsden.co.il

No comments:

Post a Comment