Results 1 to 6 of 6

Thread: automatic calc?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    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

  2. #2
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Re: automatic calc?

    You could use the DropDownList web control, making use of its SelectedIndexChanged event.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    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

  4. #4
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    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.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  5. #5
    Addicted Member
    Join Date
    Aug 2004
    Location
    Cape Town, South Africa
    Posts
    149

    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.

  6. #6
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Re: automatic calc?

    One could also do it entirely client-side through VBScript or JavaScript
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width