Javascript Disabling WebControls

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Javascript Disabling WebControls

    Hello,
    I have an ASP.Net web page populated with WebControls, such as
    textboxes and checkboxes. On this page I also have a JavaScript that
    disables these textboxes under certain events (such as "onLoad" and
    "onClick") by calling the javascript method <object>.disabled =
    <true/false>. This works visably fine on the webpage, however, when I
    do a postback to the server and check the <WebControl>.Enabled
    property on an item I disabled via the javascript it does not reflect
    its current state. Rather, it reports the Enabled property as whatever
    I initilized it to. Now I believe this is because the client is never
    communicating the enabled/disabled state change to the server. Is
    there a work around for this that doesn't require additional server
    side postbacks and validation? The whole purpose of using JavaScript
    in the first place was to avoid postbacks on checkbox clicks that
    would call server-side code to enable/disable textboxes. Any ideas are
    much appreciated.

    - Harry
    Harry Guest

  2. Similar Questions and Discussions

    1. Refering to <asp:> webcontrols
      Hey, Question, how can i create client-side javascript that refers to a asp.net webcontrol. For example set the focus of a textbox lik this. ...
    2. Serious issues with webcontrols...
      Hi, First of all, sorry for cross-posting, but some groups look more active than others, and I sure need to find an answer to this. I recently...
    3. IE WebControls
      Hi, Downloaded IEWebControls.exe application & run on local machine O/S: Win Advance Server 2000 Framework: 1.1 Notes: * During installation...
    4. Disabling LinkButton using JavaScript?
      Hi Guyz, Would appriciate any tip on disabling an ASP.NET LinkButton using client sided code like javascript. My Requirement is such that the...
    5. WebControls Button
      I have 2 HTML buttons and 1 WebControls Button on my page. I have set the 'CausesValidation' attribute of my WebControls button to False in the...
  3. #2

    Default Re: Javascript Disabling WebControls

    You could populate hidden form fields on the client when you make a
    client-side change to an object, so that when you handle the PostBack, you
    can set the properties on the server side.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    [url]http://www.takempis.com[/url]
    Complex things are made up of
    lots of simple things.

    "Harry" <robinsoh@vu.union.edu> wrote in message
    news:167a2386.0308060634.6b421630@posting.google.c om...
    > Hello,
    > I have an ASP.Net web page populated with WebControls, such as
    > textboxes and checkboxes. On this page I also have a JavaScript that
    > disables these textboxes under certain events (such as "onLoad" and
    > "onClick") by calling the javascript method <object>.disabled =
    > <true/false>. This works visably fine on the webpage, however, when I
    > do a postback to the server and check the <WebControl>.Enabled
    > property on an item I disabled via the javascript it does not reflect
    > its current state. Rather, it reports the Enabled property as whatever
    > I initilized it to. Now I believe this is because the client is never
    > communicating the enabled/disabled state change to the server. Is
    > there a work around for this that doesn't require additional server
    > side postbacks and validation? The whole purpose of using JavaScript
    > in the first place was to avoid postbacks on checkbox clicks that
    > would call server-side code to enable/disable textboxes. Any ideas are
    > much appreciated.
    >
    > - Harry

    Kevin Spencer Guest

  4. #3

    Default Re: Javascript Disabling WebControls

    When a form is posted, it sends the values of its fields to the server. It
    does not send the attributes!

    If you want to communicate client-side changes in control state to the
    server, you will need to put those changes into something which will reach
    the server. I've used both hidden fields and cookies for that purpose.
    --
    John Saunders
    Internet Engineer
    [email]john.saunders@surfcontrol.com[/email]

    "Harry" <robinsoh@vu.union.edu> wrote in message
    news:167a2386.0308060634.6b421630@posting.google.c om...
    > Hello,
    > I have an ASP.Net web page populated with WebControls, such as
    > textboxes and checkboxes. On this page I also have a JavaScript that
    > disables these textboxes under certain events (such as "onLoad" and
    > "onClick") by calling the javascript method <object>.disabled =
    > <true/false>. This works visably fine on the webpage, however, when I
    > do a postback to the server and check the <WebControl>.Enabled
    > property on an item I disabled via the javascript it does not reflect
    > its current state. Rather, it reports the Enabled property as whatever
    > I initilized it to. Now I believe this is because the client is never
    > communicating the enabled/disabled state change to the server. Is
    > there a work around for this that doesn't require additional server
    > side postbacks and validation? The whole purpose of using JavaScript
    > in the first place was to avoid postbacks on checkbox clicks that
    > would call server-side code to enable/disable textboxes. Any ideas are
    > much appreciated.
    >
    > - Harry

    John Saunders Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139