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

Postback Problem

P: n/a
I have a webform that has a listbox and two textboxes. The style
property of the text boxes are:

style="DISPLAY: none"

Based on the selection made in the listbox, one or both textboxes are
displayed using javascript. The problem comes when I submit the form.
I want the text boxes to stay displayed after submitting the form
because there will be values in them. How can I do this with .NET /
JavaScript?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Amy,

First a quick question. Do you still want the form to post back? If you do
then you don't need to use javascript at all. You can just set the text
box's visible property (not the style) to false and then when the page posts
back to the server check the drop down's value and based on that set the
necessary text box's visible property to true.

If you want to do this without posting back to the server then you'll want
to create a javascript that checks the drop down's value and resets the text
box's style tags appropriately.

To get you started, if the second scenario is what you need, I have some
javascript sample code in the code library of my web site,
www.aboutfortunate.com, that you might find helpful.

Just go to the site and then click the code library link. There is a search
box that you can use to find this sample:

Open web page from drop down list

It will show you how to use javascript to get the value selected in your
drop down list.

I don't have a sample for controlling the style tag of your text boxes but a
google search should turn up many.
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Amy Snyder" <am**@yahoo.com> wrote in message
news:OH**************@TK2MSFTNGP09.phx.gbl...
I have a webform that has a listbox and two textboxes. The style
property of the text boxes are:

style="DISPLAY: none"

Based on the selection made in the listbox, one or both textboxes are
displayed using javascript. The problem comes when I submit the form.
I want the text boxes to stay displayed after submitting the form
because there will be values in them. How can I do this with .NET /
JavaScript?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #2

P: n/a
I don't want to postback after selecting the listbox item. After
selecting the listbox item, one or both text boxes appear - I have that
working fine.

The postback is the problem. Because my style.display is initially set
to 'none' for all textboxes, after the postback all textboxes will be
hidden. I need the textboxes that were visible prior to posting to be
visible after posting. Make sense?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3

P: n/a
Amy,

After postback either clear or change the text boxes style attributes from
the code-behind page like this:

TextBox1.Attributes.Clear()

or

TextBox1.Attributes.Add("style", "[your style here]")

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Amy Snyder" <am**@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I don't want to postback after selecting the listbox item. After
selecting the listbox item, one or both text boxes appear - I have that
working fine.

The postback is the problem. Because my style.display is initially set
to 'none' for all textboxes, after the postback all textboxes will be
hidden. I need the textboxes that were visible prior to posting to be
visible after posting. Make sense?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #4

P: n/a
Thanks for the help - that worked!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.