Postback Problem

Discussion in 'ASP .Net' started by Amy Snyder, Dec 3, 2003.

  1. Amy Snyder

    Amy Snyder Guest

    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!
    Amy Snyder, Dec 3, 2003
    #1
    1. Advertising

  2. 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!
    S. Justin Gengo, Dec 3, 2003
    #2
    1. Advertising

  3. Amy Snyder

    Amy Snyder Guest

    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!
    Amy Snyder, Dec 3, 2003
    #3
  4. 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!
    S. Justin Gengo, Dec 3, 2003
    #4
  5. Amy Snyder

    Amy Snyder Guest

    Thanks for the help - that worked!



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Amy Snyder, Dec 3, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Psych971
    Replies:
    5
    Views:
    4,595
    bruce barker
    Dec 17, 2004
  2. =?Utf-8?B?Q2hhZA==?=

    Postback not being set to True on first postback

    =?Utf-8?B?Q2hhZA==?=, Apr 4, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    484
    =?Utf-8?B?Q2hhZA==?=
    Apr 4, 2005
  3. gce
    Replies:
    2
    Views:
    1,695
  4. Jacky Chau
    Replies:
    2
    Views:
    2,023
    Ninjamyst
    Jun 8, 2005
  5. Fabio Mastria
    Replies:
    5
    Views:
    4,328
    TechMCAD13
    Jan 30, 2008
Loading...

Share This Page