473,404 Members | 2,137 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,404 software developers and data experts.

Simple question for ASP AutoPostBack property

Hi, guys.
I have a web page that contains a drop-down list, a text box and a button. I set drop-down list and text box AutoPostBack property as false. When I run this page, I selected something in the drop-down list, and type some text in text box, then hit "Submit" button. I expected the result will base on what I selected and what i type in the textbox. However, it is not!

When i traced the code, I selected "PO #" in the drop-down list and I typed "12345" in TextBox2 then I hit "Submit" button. However, the following code:

Expand|Select|Wrap|Line Numbers
  1.  
  2.         If DropDownList1.SelectedItem.Text = "PO #" And TextBox2.Text <> "" Then
  3.             op_po = 1
  4.         Else
  5.             op_po = 0
  6.         End If
  7.  
gave me op_po = 0. I found that DropDownList1.SelectedItem.Text does return "PO #" but TextBox2.Text is NOTHING. I guess the reason might be when I hit submit button, the drop-down list will post back, and then the value in TextBox2 is lost. If I set Drop-down list AutoPostBack as True, then whenever I select in the list, the whole page will load it again, which is not i want.

Anyone got an idea how to resolve this?
Jan 29 '07 #1
2 1917
jhardman
3,406 Expert 2GB

Expand|Select|Wrap|Line Numbers
  1.  
  2.         If DropDownList1.SelectedItem.Text = "PO #" And TextBox2.Text <> "" Then
  3.             op_po = 1
  4.         Else
  5.             op_po = 0
  6.         End If
  7.  
I'm interested in seeing your form code.

Have you tried:

request.form("TextBox2") <> ""

in place of :

TextBox2.Text <> ""

in the handler?
This could work depending on how you structured your form.
Jan 31 '07 #2
I'm interested in seeing your form code.

Have you tried:

request.form("TextBox2") <> ""

in place of :

TextBox2.Text <> ""

in the handler?
This could work depending on how you structured your form.

I guess I know where I went wrong.

Somewhere in my codes I had a event handler for dropdownlist1.selectedindexchanged. And I put textbox2.text = "" there. So that's why whenever I changed my selection, contents in textbox2 will be removed. But thanks for giving suggestions anyway.

Cheers
Feb 2 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: gordon | last post by:
Hi Could someone tell me how to get a combobox in a class library to do the equivilent of an asp autopostback? thanks Doug
3
by: Lloyd Sheen | last post by:
I have a page that works fine. I am trying to optimize the page by overriding some of the Information that is being saved in the hidden VIEWSTATE. If I make the properties of the dropdown False...
8
by: Matthew Louden | last post by:
why need to set autopostback property to be true?? I know autopostback event means to send the form to the server automatically. I tried checkbox, checkbox list, radio button, and radio button...
1
by: Edward | last post by:
I am having a terrible time getting anything useful out of a listbox on my web form. I am populating it with the results from Postcode lookup software, and it is showing the results fine. What...
3
by: trialproduct2004 | last post by:
hi all i am new to asp.net can some one tell me use of autopostback of dropdownlist. When i set this property to true my selectionchanged event is getting fired. but when this property is set to...
2
by: Bob Peek | last post by:
I have created a master page with a single asp:button that posts the page without page validation. On the content page, I have a variety of asp controls including text box, drop down list...
4
by: Sarita Sai Bhushan | last post by:
Hi, While I was developing a active desktop web page in ASP.Net using server controls I faced a problem with the autopostback property of server control. The sever control I used in my aspx page...
2
by: rn5a | last post by:
Assume that a user control has a TextBox (Page1.ascx) <asp:TextBox ID="txtName" runat="server"/> I am encapsulating the above user control in a ASPX page named Page1.aspx i.e. the ASPX page...
2
by: Eric | last post by:
Simple problem - binding Visible property of label to Checked property of radiobutton on the same form. How do I do that in VS2005?? Visible="<%# radiob.Checked %>" - DOESN'T WORK It was so...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.