Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > viewstate on controls that are not enabled ?

Reply
Thread Tools

viewstate on controls that are not enabled ?

 
 
Adrian Parker
Guest
Posts: n/a
 
      05-03-2005
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



 
Reply With Quote
 
 
 
 
Bruce Barker
Guest
Posts: n/a
 
      05-03-2005
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
>
>
>



 
Reply With Quote
 
 
 
 
Adrian Parker
Guest
Posts: n/a
 
      05-03-2005
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
>>
>>
>>

>
>



 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      05-04-2005
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.)

 
Reply With Quote
 
Adrian Parker
Guest
Posts: n/a
 
      05-04-2005
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.)
>



 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      05-04-2005
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.)

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Page error when viewstate of list controls enabled nateastle ASP .Net 1 05-28-2009 10:55 AM
Viewstate enabled and set, but not all data is being stored in thepage Keith Murray ASP .Net 1 10-02-2005 12:08 AM
ViewState for Enabled Property on CheckBox/RadioButton Controls Leo J. Hart IV ASP .Net 5 10-10-2004 04:00 AM
Enabled property conflicts with ViewState? Cipher ASP .Net 3 04-30-2004 03:30 PM
trace enabled, get app. error, doesn't enabled, on runs without error Gabor ASP .Net 3 08-26-2003 09:54 AM



Advertisments