Вопрос

I want to create at runtime some items that must not hit the "async postback".

Actually I have a button for each row in my grid view. This controls must not generate the partial postback but the complete postback ('cause the result must be the download of a report).

Actually I tried in 2 ways:

  1. On page load

    • recursive search for every controls that is a Button and have the specified class
    • add the item to the ScriptManager via:

      ScriptManager.GetCurrent(this).RegisterPostBackControl(control);

    • this code is hitted the right number of time, but partial postback is still generated

  2. On item generation

    • I add a "OnDataBinding" event to the button generation
    • in this event I do something like:

      var button = (Control)sender;

      ScriptManager.GetCurrent(this).RegisterPostBackControl(button);

Why isn't this working?

In both cases I hit the specific case and "register" the controls as "do full postback" so way do I get the partial one?

Thank you

Это было полезно?

Решение 2

I find out a solution that works and that does not involve any particular code / overriding.

I was focussing on the single "automatically-generated" button but when I start thinking about areas and parents everything goes fine.

As solution I simply register the WHOLE GridView to the Script Manager, by this way, all the controller inside generates a full postback instead of a partial one.

In my Page_Load I have now:

        ScriptManager.GetCurrent().RegisterPostBackControl(grd_Reports);

Другие советы

I don't know what you mean by partial postback but I guess you are trying to do something on button click event which you want to occur after page load. There is a quick walkaround for this, on pageload event you can check which button was clicked.

if(IsPostBack){
    clickedButtonID=Request.Form["__EVENTTARGET"]; 
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top