|
-
Apr 13th, 2011, 09:20 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Drop Down Combo
So i'm fairly new to the web dev. been a forms programmer most of my career. I'm developing a web page. I have a drop down combo, and a button. When I click the button, I want to be able to get the selected text value of the combo. However, when I do this, it always gives me the first value and when the page "refreshes", the combo returns back to the first selected index.
I'm sure this is a dumb question, but like i said i'm new to the WEB portion of VB.
please help.
thanks.
-
Apr 14th, 2011, 03:00 AM
#2
Re: Drop Down Combo
Thread moved and irrelevant posts deleted.
-
Apr 14th, 2011, 05:39 PM
#3
Re: Drop Down Combo
Not much without your code but a guess:
Use your code inside If Not Page.IsPostBack .
If you press the button the page will do a partial refresh and if your code is outside the ispostback statement i will be re-executed thus recreating the combo.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Apr 18th, 2011, 08:23 AM
#4
Thread Starter
Addicted Member
Re: Drop Down Combo
I basically have a web page, with a drop down combo, and a button. When I click on the button, want to get the selectedindex of the combo and let's say put that value in a textbox already on the page.
WHen I do this, I always get the value of 0 no matter which selection I choose from the drop down.
-
Apr 18th, 2011, 05:04 PM
#5
Frenzied Member
Re: Drop Down Combo
yes that's true ,
agreed with sapator
because you Populate your DropDownList each time when your page is postback
so you need to prevent it from being Populated at the first time.
using
Code:
if(!IsPostBack){
// here Populate your DropDownList
}
this will give you the solve to your Problem
You Don't Have to Rate Me.
I'm Not a Civilized Man I'm the Civilization it self
White or Black, Living or Dieing and 0 or 1 that's MY life
iam an Object in Object Oriented Life
my blog : http://refateid.blogspot.com/
twitter : @avrail
010011000111010101110110001000000100110101111001001000000101000001100011 
-
Apr 19th, 2011, 07:54 AM
#6
Thread Starter
Addicted Member
Re: Drop Down Combo
Thank You! I used it and is now working
-
Apr 19th, 2011, 10:07 AM
#7
Frenzied Member
Re: [RESOLVED] Drop Down Combo
You Don't Have to Rate Me.
I'm Not a Civilized Man I'm the Civilization it self
White or Black, Living or Dieing and 0 or 1 that's MY life
iam an Object in Object Oriented Life
my blog : http://refateid.blogspot.com/
twitter : @avrail
010011000111010101110110001000000100110101111001001000000101000001100011 
-
Apr 20th, 2011, 01:49 AM
#8
Re: [RESOLVED] Drop Down Combo
Hello,
The crux of the problem that you were having is with regard to the ASP.Net Page Life Cycle, which is very different to how things work in Windows Forms Applications.
I would highly recommend that you take a look at the following:
http://msdn.microsoft.com/en-us/library/ms178472.aspx
And have a play with it. Set some breakpoints in each of the events that it mentions, and get a solid understanding on how it works.
Any questions, feel free to ask.
Gary
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|