updating a hidden field from OnClick

  • Thread starter Thread starter PJ6
  • Start date Start date
P

PJ6

In a page I register a hidden field in the c'tor or OnPreRender like so -

Public Sub New()
Me.RegisterHiddenField("TEST", "")
End Sub

In an inherited control I want to update this hidden field like so -

Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)
Me.Attributes.Add("onClick", "document.forms[0]." & _
"TEST.value='" & SomeValue & "';document.forms[0].submit();")
MyBase.OnPreRender(e)
End Sub

For some reason, the field isn't being updated. I'm sure it's something
simple... can anyone lend me a clue?

Thanks,
Paul
 
It probably actually IS... but since you are posting back to the server the
control value is being reset again..
Look at the IsPostBack() to exclude it from being reset again.
 
Back
Top