0

I would like to trigger the onchange with c# because i can't use js

        (Master.FindControl("ComboBox") as CustomComboBox).SelectedValue = foo;
        (Master.FindControl("ComboBox") as CustomComboBox).change();

the ".change()" won't work. Is there a way in c# to make it work ?

Thank you for your help.

Gromain
  • 123
  • 6
  • 1
    `change` is an event, you can't use standard method call to trigger other events in C# like JS does. You need to use `protected void ComboBox_Change(object sender, EventArgs e)` event handler in case of ASP.NET webforms code-behind. – Tetsuya Yamamoto Oct 05 '17 at 07:38

1 Answers1

1

Nope, there is no generic way to trigger another object's events in C#.

However, there is a simple workaround: Extract the code you execute in your ComboBox's onchange event into a separate method and call this method.

Heinzi
  • 167,459
  • 57
  • 363
  • 519