By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,991 Members | 1,737 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,991 IT Pros & Developers. It's quick & easy.

Question about 'hiding' form controls

P: n/a
Hi all,

I've got myself into a bit of a problem and I'm trying to dig my way back
out, in a) the quickest way due to project deadline and also b) best
approach.

I have a form which gets a set of document type properties from SQL Server,
these properties are used to create corresponding controls on the form, so
for example:

PropertyDisplayName : Surname
PropertyObjectName : txtSurname

In this very small example the "Surname" text would be displayed on the left
of the text box which would have the ID of "txtSurname".

There are currently 6 different document types - each with a set of
properties, some of the properties are common in each document type (like
surname for example).

My problem is that if my querystring does not contain the 'document type' I
dont know what type of form to give the user - therefore the form has a drop
down menu with all of the document types listed for them to select from -
this only appears if the querystring value is missing, if it is present,
then the drop down is replaced with a readonly text box with the name of the
document type in it.

What I need to do in the case of the querystring not containing a value for
the document type would be to change the controls on the form. This needs
to be achieve without a reload of the page.

Initially I was thinking that I could get all of the document types and
associated properties from the database in one go at the beginning, put each
document type into a seperate 'panel' and then show/hide the relevant
panel - my only probelm with this (untested) is that I also have validation
controls for each dynamically created control - the names for these are also
taken from the database - ie txtSurname would have the first 3 characters
dropped and then have vld added - creating vldSurname, I can foresee if I go
down this route 6 panels all sharing at least 1 control which is the same
(lets say surname) - and therefore having 6 txtSuranmes and 6 vldSurnames -
surely this will cause some form of problem as the names wont be unique.

My next thought was perhaps to create the one display with all of the
properties on it regardless of which document type they belong to and set
them all to visible = false at the start - then if they are needed by the
document type change their visible status to true. My question here is
whether or not if you set a control to visible = false whether it still gets
submitted when the form is submitted?

Any information or suggestions on this would be appreciated - if I had more
time for this I may go back and change somethings which may remove this
issue - however time has nearly run out so I need a 'best solution for now'
kinda approach.

Regards

Rob
Nov 18 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
"Rob Meade" <ro**********@NOSPAMubht.swest.nhs.uk> wrote in message
news:OC*************@TK2MSFTNGP12.phx.gbl...
Any information or suggestions on this would be appreciated - if I had more time for this I may go back and change somethings which may remove this
issue - however time has nearly run out so I need a 'best solution for now' kinda approach.


Not very fashionable these days, but you might be able to achieve what you
want with a FRAMESET.
Nov 18 '05 #2

P: n/a
"Mark Rae" wrote ...

Hi Mark - thanks for your reply.
Not very fashionable these days,
you mean the 'approach'?
but you might be able to achieve what you want with a FRAMESET.


as in the HTML frameset...I'd never live it down if I started using frames
within my applications....

Would the control.visible = false not simply remove the control from the
rendered page?

Regards

Rob
Nov 18 '05 #3

P: n/a
Hi Mark, I just re-read what you'd reply with - like duh me...I see what you
are saying now - ie, Framesets are not overly fashionable....

lol...need more sleep! :)

Rob
Nov 18 '05 #4

P: n/a
"Rob Meade" <ro**********@NOSPAMubht.swest.nhs.uk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...

Rob,
Not very fashionable these days,
you mean the 'approach'?


Yes.
but you might be able to achieve what you want with a FRAMESET.


as in the HTML frameset...I'd never live it down if I started using frames
within my applications....


I know what you mean... :-)
Would the control.visible = false not simply remove the control from the
rendered page?


If it's a server-side control, yes it would.
Nov 18 '05 #5

P: n/a
"Rob Meade" <ro**********@NOSPAMubht.swest.nhs.uk> wrote in message
news:e0**************@tk2msftngp13.phx.gbl...
Hi Mark, I just re-read what you'd reply with - like duh me...I see what you are saying now - ie, Framesets are not overly fashionable....

lol...need more sleep! :)


LOL!
Nov 18 '05 #6

P: n/a
"Mark Rae" wrote ...
If it's a server-side control, yes it would.


Hi Mark,

yep - they are all server side controls, I just wondered how far the
'ignore' affect kinda works - ie, if I set them to false are they not even
in the HTML code on the page, or more likely, are they in the HTML but have
style which hides them? my concern is that although I hide a whole table
row which has a text box and a validator control in it - would the validator
still be fired for that control even though the user has no way to put any
info in the box...this might cause a bit of a problem etc..

Reg's

Rob
Nov 18 '05 #7

P: n/a
"Rob Meade" <ro**********@NOSPAMubht.swest.nhs.uk> wrote in message
news:un**************@TK2MSFTNGP09.phx.gbl...
yep - they are all server side controls, I just wondered how far the
'ignore' affect kinda works - ie, if I set them to false are they not even
in the HTML code on the page, or more likely, are they in the HTML but have style which hides them?
Nope. Setting a server-side's visible property to false will mean that
ASP.NET will not render the HTML for that control.
my concern is that although I hide a whole table
row which has a text box and a validator control in it - would the validator still be fired for that control even though the user has no way to put any
info in the box...this might cause a bit of a problem etc..


Gosh. To be truthful, I don't actually know! However, I would strongly doubt
it...
Nov 18 '05 #8

P: n/a
"Mark Rae" wrote ...
Nope. Setting a server-side's visible property to false will mean that
ASP.NET will not render the HTML for that control.
Marvellous - I think.....however....just thinking this through.....if I was
therefore to set all of the form controls to hidden when the page loads
(assuming I've not received the required value in the querystring) - if I
then had an selected item changed event on the drop down box - could I use
that to then 'show' the controls back on the page? The only way I see that
working is if the page was reloaded - as you have mentioned - if it doesn't
render the html at all then it would have to run off and come back again
wouldn't it?
Gosh. To be truthful, I don't actually know! However, I would strongly

doubt it...

If the html doesn't get rendered then this wouldn't be a problem - but of
course raises the issue of the page perhaps having to be reloaded when the
drop down value is changed...

Thanks for your help Mark - I'll give it ago when I get 5 mins (he says
optomistically as if I could actually do this in 5 mins!) - and let you know
what happens!

Reg's

Rob
Nov 18 '05 #9

P: n/a
"Rob Meade" <ro**********@NOSPAMubht.swest.nhs.uk> wrote in message
news:uM**************@TK2MSFTNGP09.phx.gbl...
Thanks for your help Mark - I'll give it ago when I get 5 mins (he says
optomistically as if I could actually do this in 5 mins!) - and let you know what happens!


I'd be interested to know the outcome, as what you're trying to do is
something I've never had a need to do!
Nov 18 '05 #10

P: n/a
"Mark Rae" wrote ...
I'd be interested to know the outcome, as what you're trying to do is
something I've never had a need to do!


Hi Mark,

I will do - probably be next week now before I get an opportunity try it.

Reg's

Rob
Nov 18 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.