Use LoadControl to load a usercontrol but the webcontrol in the usercontrol can not AutoPostBack

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • huobazi

    Use LoadControl to load a usercontrol but the webcontrol in the usercontrol can not AutoPostBack

    a uscontrol test.ascx have a dropdownlist web control the dropdownlist's
    AutoPostBack property is set "true"
    but when i use Loadcontrol("te st.ascx") in a aspx fiel's Page_Load event the
    dropdownlist which in the ascx can not run good it can not autopostback and
    can not call the OnselectedChang e event. help me pls~~


  • David Waz...

    #2
    Use LoadControl to load a usercontrol but the webcontrol in the usercontrol can not AutoPostBack

    I assume you are using a dynamic control--

    Be SURE the control exists when you post back to your page.
    if the control doesn't exist when the page posts back, it
    cannot receive the vent.

    so, load the control regardless of the value
    of "IsPostBack ".

    2ndly, do you add a handler when the control is first
    rendered? you need to assign some routine to handle the
    event:

    AddHandler myControl.MyEve nt Addressof MyEventHandler
    unless you are using member-level "WithEvents " variable
    for your control.
    [color=blue]
    >-----Original Message-----
    >a uscontrol test.ascx have a dropdownlist web control the[/color]
    dropdownlist's[color=blue]
    >AutoPostBack property is set "true"
    >but when i use Loadcontrol("te st.ascx") in a aspx fiel's[/color]
    Page_Load event the[color=blue]
    >dropdownlist which in the ascx can not run good it can[/color]
    not autopostback and[color=blue]
    >can not call the OnselectedChang e event. help me pls~~
    >
    >
    >.
    >[/color]

    Comment

    Working...