Asp.NET dropdownlist in usercontrol does not fire SelectedIndexChanged event

Asp.Net 2.0 framewrok - VB.Net application I have a UserControl containing Asp.Net DropDownList.

Those things that have already been researched and / or tried:

  • The control is bound to data on the page loading inside, if not Page.IsPostBack (it is loaded only once)
  • The proprety ID is set to control (ID = ddlMyControl)
  • AutoPostBack is true
  • EnableViewState on the control is set to true
  • AutoEventWireUp in UserControl declaration is true
  • EnableEventValidation is false on the parent page

The control will not fire the SelectedIndexChanged event no matter what I do. HELP!!

Thank:)

+3
source share
6 answers

I had a similar problem, and that was because I left AutoPostBack = "true" from the control definition. In your original post, you said you tried this, but published code:

<uc3:TheControl ID="ucMyControl" runat="server" />

does not reflect the AutoPostBack property. I added this to me and he took care of my problem. Hope this helps.

+4
source

I know this very late, but I thought that it would help others facing the same problem.

I assume you want to fire an SelectedIndexChangedEvent DropDownListthat is already associated with some data!
For example, [C #]

ddlMyDropDown.DataSource = listOfCustomers;
ddlMyDropDown.DataTextField = "CustomerName";
ddlMyDropDown.DataValueField = "CustomerID";
ddlMyDropDown.DataBind();
ddlMyDropDown.CauseValidation = false;

, asp.net( ).. 4.0.

+1

"". UserControl ?

? ? ( ?)

, - ;-)

0

UserControl , HTML-

<uc3:TheControl ID="ucMyControl" runat="server" />

, UserContorl - :

 Protected Sub ddlMyThing_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlMyThing.SelectedIndexChanged
    'Do event stuff here.
End Sub
0

onselectedindexchanged="ddlMyThing_SelectedIndexChanged" ddl?

0

, EnableEventValidation True.

.

http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_22405007.html

Hope this helps.

Thank,

Rajah

0
source

Source: https://habr.com/ru/post/1734422/


All Articles