PDA

View Full Version : [CLOSED] can not access FileUploadField1 on the change event in code behind?



tobros
Sep 03, 2013, 2:20 AM

Daniil
Sep 03, 2013, 4:54 AM
Hi @tobros,

I think you should remove this:

if (!X.IsAjaxRequest)

tobros
Sep 03, 2013, 5:45 AM
Hi @tobros,

I think you should remove this:

if (!X.IsAjaxRequest)

why?why?why?why?why?why?why?

Daniil
Sep 03, 2013, 11:30 AM
You are using a control's DirectEvent, i.e. a FileUploadField's Change DirectEvent.

Any DirectEvent requires a control instance on server when it fires. Since you are wrapping creating of the FileUploadField in theX.IsAjaxRequest condition, it is recreated when the Change DirectEvent fires.

Vladimir
Sep 03, 2013, 1:14 PM
ASP.NET is stateless system, any dynamic control must be recreated if it is required to handle events
For example, if you add dynamic ASP.NET button with attached event (OnClick) and don't recreate it then the event handler will not be executed
You can find many articles about dynamic ASP.NET controls