在 PreRender 上绑定控件
我一直相信绑定控件的最佳点是 PreRender。由于所有控件都已准备就绪,这是渲染等之前的最后一个阶段。这是正确的还是应该将控件绑定在不同的点?
非常感谢
路易斯
I have been led to believe that the best point to bind your controls is the PreRender. As all the controls are ready and this is the last stage before rendering etc. Is this correct or should controls be bound at a different point?
Many Thanks
Louis
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我同意在
PreRender
进行绑定。请参阅生命周期。
正如您所看到的,PreRender 在控件事件(例如单击)之后发生,这在用户通过某种单击提交表单后必须重新绑定新的/修改的数据时至关重要。
但是,如果您不必根据用户交互性进行绑定,那么在大多数情况下,您放置的位置是无关紧要的。
不过,请不要误会,根据您的逻辑,某些绑定可能必须在控件事件之前发生,以便它们与绑定数据进行交互。
I agree with binding at
PreRender
.Refer to the life cycle.
As you can see,
PreRender
occurs after the control events (such as clicking), which is essential when having to rebind new/modified data after the users submits the form with a click of some sort.But if you do not have to do binding based on user interactivity, then for the most part the place you put is irrelevant.
Make no mistake, though, depending on your logic, some bindings may have to occur before the control events for them to interact with the bound data.
这是我使用的页面生活“圣经”!
http://msdn.microsoft.com/en-us/library/ms178472.aspx
我会在 Page_Load 绑定你的控件
Here is the page life "bible" that I use!
http://msdn.microsoft.com/en-us/library/ms178472.aspx
I would bind your controls at Page_Load