![]() |
|
|
|||||||
![]() |
ASP Net - viewstate on controls that are not enabled ? |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Trying to write a page with several controls on it, some of which, depending
on the process login, are enabled and some disabled. When I click on a save button to cause a postback event to fire, the controls that are not enabled don't have their data returned, so in the UpdateClick event, the controls contain nothing. How do I get it to maintain the state even for these columns ? thanks Adrian Adrian Parker |
|
|
|
|
#2 |
|
Posts: n/a
|
the browser does not postback values for disabled fields. you will need
client script to copy the values to a hidden field. if you disable them in the code behind, save their disabled value in viewstate, then restore it on postback. -- bruce (sqlwork.com) "Adrian Parker" <> wrote in message news:%... > Trying to write a page with several controls on it, some of which, > depending on the process login, are enabled and some disabled. When I > click on a save button to cause a postback event to fire, the controls > that are not enabled don't have their data returned, so in the UpdateClick > event, the controls contain nothing. > > How do I get it to maintain the state even for these columns ? > > thanks > Adrian > > > Bruce Barker |
|
|
|
#3 |
|
Posts: n/a
|
Is there any easier way of not allowing entry of fields apart from setting
enabled to false ? "Bruce Barker" <brubar_nospamplease_@safeco.com> wrote in message news:... > the browser does not postback values for disabled fields. you will need > client script to copy the values to a hidden field. if you disable them in > the code behind, save their disabled value in viewstate, then restore it > on postback. > > -- bruce (sqlwork.com) > > > > "Adrian Parker" <> wrote in message > news:%... >> Trying to write a page with several controls on it, some of which, >> depending on the process login, are enabled and some disabled. When I >> click on a save button to cause a postback event to fire, the controls >> that are not enabled don't have their data returned, so in the >> UpdateClick event, the controls contain nothing. >> >> How do I get it to maintain the state even for these columns ? >> >> thanks >> Adrian >> >> >> > > Adrian Parker |
|
|
|
#4 |
|
Posts: n/a
|
Hi Adrian,
I think Bruce's suggestions are reasonable since disabled html input fields won't post back their values. And there hasn't any better means other than copy and store the values into other place(viewstate or sessionstaet) before disabling the entry fields. BTW, is it possbile that we don't disable them? For some control such as TextBox( <input type=text ... ), we can set it's "readonly" attribute. For example: txtName.Attributes["readonly"] = "true"; the above statement make the txtName (a textbox control) readonly( can't change its text), but its value can still be posted back to server side. In addition, we can also consider settting those control's Visible to false so as to hidden them. Hope helps. Thanks, Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.) Steven Cheng[MSFT] |
|
|
|
#5 |
|
Posts: n/a
|
Ok thanks guys, I'll give that a go.
"Steven Cheng[MSFT]" <v-> wrote in message news:... > Hi Adrian, > > I think Bruce's suggestions are reasonable since disabled html input > fields > won't post back their values. And there hasn't any better means other than > copy and store the values into other place(viewstate or sessionstaet) > before disabling the entry fields. > > BTW, is it possbile that we don't disable them? For some control such as > TextBox( <input type=text ... ), we can set it's "readonly" attribute. For > example: > > txtName.Attributes["readonly"] = "true"; > > the above statement make the txtName (a textbox control) readonly( can't > change its text), but its value can still be posted back to server side. > In addition, we can also consider settting those control's Visible to > false > so as to hidden them. > > Hope helps. Thanks, > > Steven Cheng > Microsoft Online Support > > Get Secure! www.microsoft.com/security > (This posting is provided "AS IS", with no warranties, and confers no > rights.) > Adrian Parker |
|
|
|
#6 |
|
Posts: n/a
|
OK. If there are any further questions or anything else we can help, please
always feel free to post here. Good Luck! Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.) Steven Cheng[MSFT] |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| viewstate MAC failed in asp.net 2.0 while postback the page | azraffarveen | Software | 0 | 05-12-2009 03:24 PM |
| Bizzare ViewState issue (ASP.NET) | dmartu | Software | 0 | 12-04-2008 10:26 AM |
| VLC controls | DVDfanatico | DVD Video | 1 | 01-25-2006 05:22 PM |
| VLC controls | DVDfanatico | DVD Video | 2 | 01-25-2006 12:07 AM |
| Getting Around Copy Controls | Ablang | DVD Video | 0 | 04-01-2005 06:09 AM |