0

I am needing to create some dynamic controls at Page_Load in the consumer webpart. In the Provider webpart I did some hacking and got it so I could get a controls value before viewstate is loaded in Page_Init.

So basically what I want is for webparts to be able to communicate before Page_Load.

[ConnectionConsumer("FormRID Consumer","FormRIDConsumer")]
public void InitializeProvider(MyControl.IFormRID provider)
{
    theProvider = provider;
    FormRID = theProvider.FormRID;
}

That method doesn't get called until after Page_Load. This is a big problem for me because my consumers Page_Load depends on FormRID being set and accurate. I can't move my Page_Load code into Page_LoadComplete either because I am needing to create dynamic controls with viewstate(viewstate isn't restored after Page_Load)

So is there some work around I can use so that I can communicate before Page_Load.

4

3 回答 3

1

您应该使用 OnPreRender 事件而不是 Load,因为 onLoad 发生在 WebPart 连接执行之前。

这是您可以使用 OnLoad 和 OnPreRender 事件的一个示例http://blog.mastykarz.nl/web-part-requires-clicking-twice-apply-ok-button-apply-changes/

于 2012-01-03T20:15:10.000 回答
1

您是否尝试过订阅 Web 部件区域的 Init 事件并将 InitializeProvider() 放在那里?我相信它是在用户控件和 Web 表单的 OnLoad 或 OnInit 事件之前触发的。

于 2009-10-22T16:40:59.527 回答
0

I ended up having to create my own webpart communication.

It ended up much cleaner than ASP.Net's and communication can happen as early as OnInit inside of the webparts.

于 2009-11-30T23:10:58.420 回答