Results 1 to 4 of 4

Thread: Run code on page load only once

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Europe, Lithuania
    Posts
    309

    Run code on page load only once

    Hello,

    Then page is loading (Page_Init sub), I fill my combo-box with MySQL database data.
    Then I select item and press command button. Problem is that after postback function is called, Page_init sub is called again and combo box is refilled, so my selected item is canged. How to run code only once, when page is loading?

    Ps. Sorry for my poor english.
    Last edited by Norkis; Feb 11th, 2004 at 01:01 PM.

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    First - rather move the code to Page_Load, then set EnableViewState to true, and:
    Code:
    if (!Page.IsPostBack)
    {
        // Populate the control.
    }
    Alternatively, you could use Request.Form["ComboName"]

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Europe, Lithuania
    Posts
    309
    It worked.
    Now combo isn't filled againg.

    But my problem isn't solved.
    Selected item refreshes to the top item.
    How to keep selected items in combo boxes?

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Europe, Lithuania
    Posts
    309
    I found that combobox selection is changed only when selected item contains non standart charters (ą č ę ė etc. charset cp1257).

    Isn't it a bug? How to solve this?

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