Good ClientSide or Dynamic ServerSide way to implement Read/write access to fields?

Denaes

Senior Contributor
Joined
Jun 10, 2003
Messages
956
I can't use enabled/disabled controls due to requirements for having a user friendly app (they're hard to read and you can't copy/paste from them).

So I'm working on a screen where I have duplicate Panels that I hide/show on postback. One has textboxes/dropdowns/etc and the other just displays labels (which are turned into spans) and basically shows up as text.I hate having to duplicate all the data filling and any changes made to one on the other... and I'm thinking of the other 20 screens I have to do this on.

I'm just looking for a decent way to get the "here is the readonly mode" and "here is the updatable mode with editable controls".

My one thought is to use Ajax to write HTML, but I'd lose possible server side support as well as component/control support.

I'd love to just be able to say "here is my textbox, display it like a span now". Maybe a user control that swaps textboxes for labels?

I'm using Infragistics tools, Asp.net 2.0 and MS Ajax 1.0. Any help/advice would be appreciated.
 
Doesn't the ReadOnly property for textboxes still allow them to be readable and copy paste is still ok? Just a thought...

Anyways, if I understand your post correctly, you are looking for a way to display your data two ways (read-only and editmode) and you have solved this by duplicating the editmode controls with labels correct? (or is it the other way around?)

One thing that comes to mind is approaching this through your CSS, like when you come-up with a "printer friendly" version of a page, you basically give a readonly version.
 
Container control

Maybe a user control that swaps textboxes for labels?

That would be my first instinct - a container control which holds editable controls (Textbox, DropDownList etc), but will render them as static controls (spans) depending on the value of some property. This should be quite simple to implement as well. The contents of the editable controls could be stored in the view state to provide persistence between postbacks.

Good luck :)
 
Re: Container control

Doesn't the ReadOnly property for textboxes still allow them to be readable and copy paste is still ok? Just a thought...

Maybe so. If that worked consistantly with all the basic controls without making the text nearly unreadable to anyone with less than perfect vision.

Anyways, if I understand your post correctly, you are looking for a way to display your data two ways (read-only and editmode) and you have solved this by duplicating the editmode controls with labels correct? (or is it the other way around?)

Yeah, thats the lowdown.


One thing that comes to mind is approaching this through your CSS, like when you come-up with a "printer friendly" version of a page, you basically give a readonly version.

That is very interesting. That sounds like it could be a relatively easy client-side option... well easy is relative when the only thing you know about CSS is how to set some basic skinning. I'll look into that :)

That would be my first instinct - a container control which holds editable controls (Textbox, DropDownList etc), but will render them as static controls (spans) depending on the value of some property. This should be quite simple to implement as well. The contents of the editable controls could be stored in the view state to provide persistence between postbacks.

Good luck :)

Hrmm... I think I'd have to learn how to do part of that in javascript to leave that option of swapping controls on the client. doing it severside would definately be far easier, just not the performance I'm aiming for.

Thank you both for your point of views :)
 
Pretty much. In my minds eye the border and whatnot would appear on some property change (ie, me setting it to edit or view mode in some clientside event) rather than a mouseover.
 
Yes, readonly seems to do what I want. Was this propert new to 2.0? None of the older 1.1 developers have heard of it. Maybe just something they never realized.

Just means I have to learn to dynamically swap in a combo for certain textboxes. Part of the reason for this Edit/View mode was about 800k of viewstate brought on by 10 or so comboboxes with long lists. Only loading that data when it's needed will help things out a bit
 
The readonly has been there since 1.1

Like the bulletted list in 2.0, it is one of those things that you find at about 4:45pm.. when ou are just about to leave the office.. :D

Glad you found an acceptable workaround. We'll still try to find something for those viewstate hogging dropdown of yours.
 
Back
Top