FancyPrairie
Programmer
I've created a composite control and am trying to retreive the value of one of its properties by calling one of its methods via javascript. However, when the method is called the property is nothing rather than the value I set the property to during design time. I placed breakpoints in my code behind and can see that the property is set to what I set it to at design time. In the onfocus event (client side) of my composite control I call a method that returns the value of the property. I set a breakpoint on the return statement within the method and the property has been set to "Nothing". I'm assuming that a postback has occured which caused the Property to be initialized (Nothing). So, how to I prevent the property from losing its value?
Here's some of my codebehind code:
Here's some of my clientside javascript:
Here's some of my codebehind code:
Code:
Namespace MyCompositeControls_NameSpace
<ToolboxData("<{0}:MyCompositeControl runat=server></{0}:MyCompositeControl")> _
Public Class MyCompositeControl
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AjaxPro.Utility.RegisterTypeForAjax(GetType(MyCompositeControls_NameSpace))
End Sub
<AjaxPro.AjaxProperty(), Category("Layout"), Description("Gets or sets the type of input."), DefaultValue("Default")> _
Public Property InputFormat() As string
Get
If CType(ViewState("InputFormat"), Object) Is Nothing Then Return "Nothing"
Return CType(ViewState("InputFormat"), string) 'maintained accross postback
End Get
Set(ByVal value As string)
ViewState("InputFormat") = value '1. Value equals what I set it to at design time
Me.ChildControlsCreated = False
End Set
End Property
<AjaxPro.AjaxMethod()> _
public function GetInputFormat() as string
return Me.InputFormat '2. VAlue equals default value when code gets here
end function
end class
end Namespace
Here's some of my clientside javascript:
Code:
function OnFocus(oTextBox) {
mInputFormat = MyCompositeControls_NameSpace.MyCompositeControl.GetInputFormat() '3. VAlue equals default value when code gets here
}