-
automatic calc?
Hi there. Creating an ASP.NET app.
basically, if a user selects an item from the drop down box, i want it to automatically do some simple calcs and display it in a textbox or label.
how can i do this, without the user clicking a button and doing the calculations? is there an automatic way of executing a command when the user has selected an item?
thanks :)
-
Re: automatic calc?
You could use the DropDownList web control, making use of its SelectedIndexChanged event.
-
Re: automatic calc?
i am using the dropdownlist but then what do i do?? :) data in that dropdown list is being filled in when the page is loading, it gets the data from a database
-
Re: automatic calc?
I don't use visual studio to develop asp.net project's (and can't run it), but i guess it's similar.
If you select the dropdownbox (in the design mode when you place it on the page) somewhere in the IDE there should be a list of its properties etc.
Near there will probably be a button to show its events. This will be a list (in place of its properties) listing the various events of the control you can assign functions to. One of these is the SelectedIndexChanged event. I think you can double click on this event and it'll automatically create a function for it, and set it up so that when the event fires the newly created function will run.
You put your calculation code in that function.
-
Re: automatic calc?
You must set the AutoPostBack property of the dropdownlist to True. It will then postback to the server when the user selects an item from the list, and you can use the SelectedIndexChanged event to do the calculations.
-
Re: automatic calc?
One could also do it entirely client-side through VBScript or JavaScript