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.

1
  • 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. Commented Oct 5, 2017 at 7:38

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.