TextBox value and Javascript

Discussion in 'ASP .Net' started by Hardy Wang, Aug 12, 2004.

  1. Hardy Wang

    Hardy Wang Guest

    Guys,
    I have a web form with some <Asp:TextBox> controls, on some condition, I
    need to trigger a client side JavaScript to clean all values of these boxes,
    like below:

    function DisableForm() {
    document.getElementById("UserCtrl_Text_97").value = "";
    document.getElementById("UserCtrl_Text_97").disabled = true;

    document.getElementById("UserCtrl_Text_98").value = "";
    document.getElementById("UserCtrl_Text_98").disabled = true;

    document.getElementById("UserCtrl_Text_99").value = "";
    document.getElementById("UserCtrl_Text_99").disabled = true;

    document.getElementById("UserCtrl_Text_100").value = "";
    document.getElementById("UserCtrl_Text_100").disabled = true;
    }

    The problem is, when I click "Save" button, all original data with these
    text boxes are posted to server, instead of empty values.

    Anybody knows why?

    --
    WWW: http://hardywang.1accesshost.com
    ICQ: 3359839
    yours Hardy
    Hardy Wang, Aug 12, 2004
    #1
    1. Advertising

  2. When you disable a control, its values are not posted back. So the control
    is pulling its previous value from viewstate.

    HTH,

    bill


    "Hardy Wang" <> wrote in message
    news:...
    > Guys,
    > I have a web form with some <Asp:TextBox> controls, on some condition,

    I
    > need to trigger a client side JavaScript to clean all values of these

    boxes,
    > like below:
    >
    > function DisableForm() {
    > document.getElementById("UserCtrl_Text_97").value = "";
    > document.getElementById("UserCtrl_Text_97").disabled = true;
    >
    > document.getElementById("UserCtrl_Text_98").value = "";
    > document.getElementById("UserCtrl_Text_98").disabled = true;
    >
    > document.getElementById("UserCtrl_Text_99").value = "";
    > document.getElementById("UserCtrl_Text_99").disabled = true;
    >
    > document.getElementById("UserCtrl_Text_100").value = "";
    > document.getElementById("UserCtrl_Text_100").disabled = true;
    > }
    >
    > The problem is, when I click "Save" button, all original data with these
    > text boxes are posted to server, instead of empty values.
    >
    > Anybody knows why?
    >
    > --
    > WWW: http://hardywang.1accesshost.com
    > ICQ: 3359839
    > yours Hardy
    >
    >
    William F. Robertson, Jr., Aug 12, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eph0nk
    Replies:
    2
    Views:
    38,931
    Eph0nk
    Aug 6, 2003
  2. =?Utf-8?B?QW5hY2hvc3RpYw==?=

    RE: Textbox postback putting value,value

    =?Utf-8?B?QW5hY2hvc3RpYw==?=, Jun 18, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    632
    =?Utf-8?B?S2VpdGggRG9yYW4=?=
    Jun 21, 2004
  3. AGSHAR
    Replies:
    1
    Views:
    591
    AGSHAR
    May 31, 2008
  4. ErwinP
    Replies:
    1
    Views:
    736
    ErwinP
    Aug 19, 2005
  5. Steve
    Replies:
    4
    Views:
    208
    Steve
    Feb 7, 2006
Loading...

Share This Page