ASCX 负载与 ASPX 负载

发布于 2024-08-16 12:45:12 字数 102 浏览 2 评论 0原文

我真的不能说我完全理解他们如何互动。 特别是当我在 ASCX Load 事件中说 if(Page.IsPostBack) 时,它是什么意思。父ASPX是回发的吗?

提前致谢

I can't really say I fully understand hopw they interact.
Especially when I say if(Page.IsPostBack) in an ASCX Load event, what does it mean. The parent ASPX is postback?

thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤者何惧 2024-08-23 12:45:12

你是对的。 bool 属性 Page.IsPostBack 将告诉您包含 ascx 控件的 aspx 页面是否已提交给自身。 Page 对象指的是 aspx 页面。

You are correct. The bool property Page.IsPostBack will tell you if the aspx page containing the ascx control has been submitted to itself. The Page object refers to the aspx page.

橘虞初梦 2024-08-23 12:45:12

这可能有助于您理解该过程:

在 .aspx 页面上的 Page_Load 上放置一个断点,并在用户控件中的 load 事件上放置另一个断点。运行应用程序并查看事件顺序。

在两个地方创建 Init 事件也可能会有所帮助,这样您就可以逐步浏览它们并查看差异。

如果您当前的代码有点复杂,您可能需要为此目的创建一个单独的示例项目。制作一个“Hello world”.ascx 并将其放在“Welcome”.aspx 上,设置所有断点并单步执行代码。

就我个人而言,我认为这种方法比仅仅阅读它更容易理解和记住。

This might help you understand the process:

Put a breakpoint on Page_Load on the .aspx page, and another breakpoint on the load event in the user control. Run the app and view the sequence of events.

It might also be helpful to create Init events in both places, just so you can step through them and see the differences.

If your current code is a bit complex, you might want to create a separate sample project just for this purpose. Make a "Hello world" .ascx and put it on a "Welcome" .aspx, set all the breakpoints and step through the code.

Personally, I think this approach is easier to understand and remember than just reading about it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文