Simple Form w/ Edit Button

1 posts, 0 answers
  1. George
    George avatar
    13 posts
    Member since:
    Jun 2013

    Posted 15 Mar 2014 Link to this post

    I want to build a form where each entry field is either pre-populated
    with data from SQL and 'Read Only' (doesn't have to be 'readonly'
    strictly speaking but I don't want it to be editable, like a textbox
    that's disabled or a label) with an 'edit' button next to the field that
    makes it editable, or if there is no data for the field, have it be an
    editable textbox.

    The wrinkle is that I want the 'edit' buttons
    to work client-side.  I've tried javascripts that toggle the 'readonly'
    attribute of textboxes, (which I couldn't make work) and I've tried
    javascripts that enable/disable the textboxes (which also didn't work). 
    Someone the problem I had with these first two approached were with
    poastback.  I want to retrieve the value from each field whether it's
    been edited or not at postback, and I want the value to return as
    whatever it has been changed to after postback.  I had trouble with
    both.

    I've even tried having two controls, a label and a textbox,
    with linked values where only one of the two is ever visible.  I had
    trouble getting this approach to render correctly using client-side
    code.

    Is there an approach that is 'best practice' or that most people use for this?

    Thanks.
Back to Top