Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - viewstate on controls that are not enabled ?

 
Thread Tools Search this Thread
Old 05-03-2005, 08:27 PM   #1
Default viewstate on controls that are not enabled ?


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
  Reply With Quote
Old 05-03-2005, 09:08 PM   #2
Bruce Barker
 
Posts: n/a
Default Re: viewstate on controls that are not enabled ?
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
  Reply With Quote
Old 05-03-2005, 09:26 PM   #3
Adrian Parker
 
Posts: n/a
Default Re: viewstate on controls that are not enabled ?
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
  Reply With Quote
Old 05-04-2005, 04:51 AM   #4
Steven Cheng[MSFT]
 
Posts: n/a
Default Re: viewstate on controls that are not enabled ?
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]
  Reply With Quote
Old 05-04-2005, 07:35 AM   #5
Adrian Parker
 
Posts: n/a
Default Re: viewstate on controls that are not enabled ?
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
  Reply With Quote
Old 05-04-2005, 07:43 AM   #6
Steven Cheng[MSFT]
 
Posts: n/a
Default Re: viewstate on controls that are not enabled ?
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]
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

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




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

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