开发者

What if you want webpart communication before Page_Load?

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_In开发者_运维问答it.

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.


Have you tried subscribing to the web part zone's Init event and placing your InitializeProvider() there? I believe it is fired before OnLoad or OnInit events of user controls and web forms.


You should use on OnPreRender event instead of on Load, beause onLoad occurs before WebPart connection executes.

Here is one example of what you could expect using OnLoad and OnPreRender events http://blog.mastykarz.nl/web-part-requires-clicking-twice-apply-ok-button-apply-changes/


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜