updating a hidden field from OnClick

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
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top