سؤال

I'm developing simple WebForms application, where I'm trying to catch simple click event of Button ASP.NET Control from the UpdatePanel.

Button wasn't added in MarkUp part of project. It was added dynamically from the CodeBehind and also event was added dynamically too to the static class.

Here is code: http://ideone.com/bnntkb (CodeBehind only, because MarkUp holds just only the ScriptManager and UpdatePanel controls ).

First of all, I think the issue related to the Page.IsPostback and I have tried to use:

if (Page.IsPostBack) PageSetup();

But nothing happens, it just not firing the .Click event either.

Why do I have such a problem and how to fix it?

Thanks!

هل كانت مفيدة؟

المحلول

Please see what happens when you put PageSetup() into the Page Init procedure. Dynamically created controls are supposed to be created there. Maybe some UpdatePanel initialization takes place earlier in the Page Life Cycle.

Also, dynamically created controls must be created each time the Page is created, even in PostBacks.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top