User Control (ASP.Net)

User Controls
When dealing with User Controls in the ASP.Net application, sometimes the post back to the code behind page does not happen as anticipated. For example, when you decide to bind a Control dynamically to the HTML templated and then assign an event handler to the Control bound, the postback always happens to the main page then transferred to the User Control code-behind, there are always tedious steps that have to happen. Sometimes this postbacks does not trigger the event handler of the Control and would end in the Page.Load() event. This becomes really hectic to debug when the User Control does not post to the intended code-behind class. Event Handler does not work as needed.


One way to overcome this problem is to use Sessions and Javascript. Create a function on the Front-end and bind the function to the control created dynamically or at Run-Time. This way, the Front-End will trigger the event and then puts the values like a Controls ID in a session for other pages to use. Core 3.1 mvc core errors web forms core tutorial Technology published

Was this page helpful?

Yes Yes! this solution to the problem was helpful. No No! this solution to the problem was not helpful.. Leave ErnesTech Feedback.Feedback
Login to Continue

Community of Software Developers

Welcome, log in to continue reading. It's free and only takes a minute.

© 2020 - ErnesTech - Privacy