I’m creating a server control, which has a property that I am adding as an expando attribute. It works on the initial page load, but after a partial postback, it stops working. My expando attribute is gone.
The class is a class derived from a telerik RadButton.
This is what I am doing in the overridden PreRender method:
Dim radContextMenu As RadContextMenu = Parent.FindControl(ContextMenuID)
If radContextMenu IsNot Nothing Then
'register the name of our context menu so we can access it from javascript
ScriptManager.RegisterExpandoAttribute(Me, Me.ClientID, "ContextMenuClientID", radContextMenu.ClientID, False)
End If
As you can see, I’m using ScriptManager, which is supposed to work in partial postback senarios (and it has for other projects of mine) but RegisterExpandoAttribute doesn’t seem to work here. Also, I have stepped through the code as well and determined that radContextMenu is indeed found by FindControl.
Any insight as to what I’m doing wrong would be greatly appriciated. Thank you
Resolved similar issue by adding check for page’s
ScriptManager.IsInAsyncPostBackproperty. When it is set tofalseyou should use<control>.Page.ClientScript.RegisterExpandoAttributemethod.I ended up with new extension method for
Controlcontaining this logic: