Repost : Protecting a textbox from input

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    Repost : Protecting a textbox from input

    Hi all,

    I have a gridview with bound controls and some column templates. One of
    these column templates is a textbox which is used for running totals. I
    don't want the user to edit this so I merely set the enabled property to
    false. The problem I'm having is that when the page posts back to the server
    then back to the client again, the viewstate is gone and it's initialazed to
    0.

    How can I keep the viewstate and yet prevent the user from editing the
    values client-side?

    Regards
    John.




  • Peter Rilling

    #2
    Re: Repost : Protecting a textbox from input

    First, you could just make is a label rather then a textbox.

    Second, you need to ensure that the control gets recreated sometime during
    the Init event because the viewstate loads sometime between the Init and
    Load.

    "John" <a@b.com> wrote in message
    news:u1zZzhqwFH A.3696@TK2MSFTN GP10.phx.gbl...[color=blue]
    > Hi all,
    >
    > I have a gridview with bound controls and some column templates. One of
    > these column templates is a textbox which is used for running totals. I
    > don't want the user to edit this so I merely set the enabled property to
    > false. The problem I'm having is that when the page posts back to the
    > server
    > then back to the client again, the viewstate is gone and it's initialazed
    > to
    > 0.
    >
    > How can I keep the viewstate and yet prevent the user from editing the
    > values client-side?
    >
    > Regards
    > John.
    >
    >
    >
    >[/color]


    Comment

    • John Timney \(ASP.NET MVP\)

      #3
      Re: Repost : Protecting a textbox from input

      have you tried using the clientside onfocus event, you could probably
      setfocus to another screen area should the texbox recieve focus whihc should
      still allow the value to be updated. Alternatively, you could always use a
      label.

      --
      Regards

      John Timney
      ASP.NET MVP
      Microsoft Regional Director

      "John" <a@b.com> wrote in message
      news:u1zZzhqwFH A.3696@TK2MSFTN GP10.phx.gbl...[color=blue]
      > Hi all,
      >
      > I have a gridview with bound controls and some column templates. One of
      > these column templates is a textbox which is used for running totals. I
      > don't want the user to edit this so I merely set the enabled property to
      > false. The problem I'm having is that when the page posts back to the
      > server
      > then back to the client again, the viewstate is gone and it's initialazed
      > to
      > 0.
      >
      > How can I keep the viewstate and yet prevent the user from editing the
      > values client-side?
      >
      > Regards
      > John.
      >
      >
      >
      >[/color]


      Comment

      Working...