Test if control state has changed after postback

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to add a test in my button event handler to see if one of the
controls has changed state. In this case, every time a dropdown list item has
been changed to 'Complete' status, I want save the current date to the
database as the completed date. I just need to know if the control has
changed from its pervious selected value or not.

Thanks

Earl
 
The only way would be to store the initial value somewhere (viewstate is a
good spot) then on button click retrieve the new selected value and compare
it to the value in the dropdown

sub button_click

dim oldValue as string = cstr(viewstate("previousValue"))
if oldValue <> ddl.SelectedValue then 'you might wanna check for null or
initialize the viewstate("previousValue") on the initial page_load
'value has changed, do whatever
viewState("previousValue") = ddl.SelectedValue 'store the new value as
the previous one
end if
end sub

Karl
 

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

Back
Top