Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo jumps to index 0 3

Status
Not open for further replies.

RonRepp

Technical User
Feb 25, 2005
1,031
US
I have an asp page (2008) that works well. The dropdown is populated via a SQL DB. The page also has a button, which right now is only hooked to a msgbox.

When I click the button, the msgbox fires, and when I click on the msgbox OK button, the dropdown reverts to index 0.

Any ideas?

Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.

My newest novel: Wooden Warriors
 
The page also has a button, which right now is only hooked to a msgbox.
you mean like a message box for WinForms? if so this won't work once deployed to a server. the Message Box will open on the server, not the client and the page will hang waiting for the message box to close.

if you mean a javascript message box, you're OK.

also, you do not mention selecting an item from the dropdown, or changing the index, or anything like that. Without interaction with the dropdown the default selected index is -1 (nothing selected) or 0 1st item selected.

you will need to show the code for further assistance.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Clicking a button causes a postback unless you have some js to supress the post back. I suspect that you are reloading your dropdown list in the page_load event on every load of the page.
 
Jason & JB:

Yes, the msgbox is merely there as a placeholder and is WinForm.

The dropdown has been selected to something other than the first item in the list.

Are you telling me that I need a postback for every button click? Also, do I need Java?

I thought 2008 was so robust?

Thanks,


Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.

My newest novel: Wooden Warriors
 
no, you do not need java. you may need javascript (infact webforms does create some javascript for you automatically).

Are you telling me that I need a postback for every button click?
that depends :)
if you want a button click to execute some javascript code then no, a postback is not needed.
if you want to execute code on the server yes, you need to send a request to the server and then render the response. This is true for any web environment. it's the nature of request/response communication.

the .net framework, asp.net (and maybe webforms:) ) are robust platforms. like any platform you need to understand what problems it is meant to solve and how it goes about solving those problems.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
sounds like the drop down is being bound again on postback, just wrap you bind function with

if (!(isPostBack)) {} so you only bind it once.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top