I am creating a button in the code behind of my aspx.cs page. However I need to detect within this textbox when any text is changed within it after it has been created.
TextBox addn = new TextBox
{
ID = "Tb_Address" + i,
CssClass = "TextBoxProfile",
OnTextChanged = "textChangedEventHandler",
Text = "testc"
};
Tb_Container.Controls.Add(addn);
However OnTextChanged gives me this error:
'System.Web.UI.WebControls.TextBox.OnTextChanged(System.EventArgs)' is inaccessible due to its protection level
I have read around these issues; but I don't have a designer page to change the protection level, neither do I think that would work as these controls are created programmatically.
Edit:
I had tried:
addn.OnTextChanged += textChangedEventHandler;
However this still gives me the above error.
addn.TextChanged += textChangedEventHandler;
The above works, but it's not the desired output, as I wish for this to be automatic and not on PageLoad(?).