Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Postback Problem

Reply
Thread Tools

Postback Problem

 
 
Amy Snyder
Guest
Posts: n/a
 
      12-03-2003
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!
 
Reply With Quote
 
 
 
 
S. Justin Gengo
Guest
Posts: n/a
 
      12-03-2003
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" <> wrote in message
news:...
> 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!



 
Reply With Quote
 
 
 
 
Amy Snyder
Guest
Posts: n/a
 
      12-03-2003
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!
 
Reply With Quote
 
S. Justin Gengo
Guest
Posts: n/a
 
      12-03-2003
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" <> wrote in message
news:%...
> 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!



 
Reply With Quote
 
Amy Snyder
Guest
Posts: n/a
 
      12-03-2003
Thanks for the help - that worked!



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
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
Using callback, I fill dorpdownlist without postback but it gets empty when a postback is executed Fabio Mastria ASP .Net 5 01-30-2008 09:07 PM
ShowDialogModal postback on close (this is not related to multiple dialogs opening upon postback) Jacky Chau ASP .Net 2 06-08-2005 05:49 PM
Can I raise a postback ? Session variable only visible after postback. Please help gce ASP .Net 2 05-08-2005 05:55 AM
Postback not being set to True on first postback =?Utf-8?B?Q2hhZA==?= ASP .Net 2 04-04-2005 06:17 PM
effecting postback without auto postback controls Psych971 ASP .Net 5 12-17-2004 08:53 PM



Advertisments
 



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 47 48 49 50 51 52 53 54 55 56 57