473,386 Members | 2,042 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Postback Problem

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
4 1834
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Igor Belagorudsky | last post by:
Hi, i am trying to analyze data submitted in a form but the problem is that when i try to create the controls in code (which is what i want to do), it throws an obect not found exception on...
0
by: Xavier Osa | last post by:
Hi, I have an ASP.Net web page that you can download a file. As Fergunson's problem, it prompts twice dialog boxes only if I select Open button. If I select Save button, it prompts once. I'm...
1
by: Mad Scientist Jr | last post by:
I don't know how this is happening, but a dropdown control I have is resetting to the 2nd value on the list anytime a postback occurs. I have no initiation code outside of If Not (IsPostBack) ...
10
by: Krista Lemieux | last post by:
I'm new to ASP.NET and I'm not use to the way things are handled with this technology. I've been told that when I have a control, I should only bind the data to it once, and not on each post back...
2
by: RAJ | last post by:
In our multi-tier application, we have several ASP.NET user controls which will update the same data source provided by middle tier logic. In this particular scenario we have one user control...
6
by: | last post by:
Hi all, I have a bunch of dropdownlists that are populated in client-side javascript. When i do a postback I get the following error:- Invalid postback or callback argument. Event...
1
by: Timbo | last post by:
Hi all, This is my first message here so i'll try and include all the information that will help you help me out, if possible. Basically I am using C# in ASP.NET 2.0 and have a Repeater...
1
by: Jason | last post by:
I have a webpage that I've wrapped in an Atlas UpdatePanel. This page contains four textboxes, each with AutoPostBack set to true. The problem comes when someone edits the first box and tabs to...
11
by: antonyliu2002 | last post by:
I know that this has been asked and answered thousands of times. As a matter of fact, I know that I need to say If Not Page.IsPostBack Then 'Do something End If for things that needs to be...
15
by: mc | last post by:
I'm writing an app for managing Task Lists, I'm trying to add some controls to a form that I can use to link tasks, my original intention was to: - Add two list boxes, one listing "all Tasks"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.