Silverlight - 动态创建控件,无需任何回发

发布于 2024-09-25 05:44:33 字数 194 浏览 2 评论 0原文

我可以在 Silverlight 中动态创建控件而无需回发到服务器(甚至是异步回发)吗? silverlight拖放是否需要回发?

我问这个问题是因为我有一个 ASP.NET 应用程序,我可以在其中动态创建/删除大量控件。因此,在回发后,我收到视图状态错误,指出控制树与视图状态树不匹配。

在 Silverlight 中我可以避免此类问题吗?

Can I dynamically create controls in Silverlight without a postback to the server (even an asynchronous one). Does silverlight drag-n-drop requires postback?

I'm asking this because I've an asp.net application where I dynamically create/delete lots of controls. So after the postback I'm getting error with view state stating that the control tree doesn't match the view state tree.

Can I avoid such problems in Silverlight?

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

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

发布评论

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

评论(4

野味少女 2024-10-02 05:44:33

silverlight 控件/应用程序中完成的所有操作都发生在客户端上。 Web 服务调用(如果有异步发生)。这就是使用 silverlight 的优点

everything done in a silverlight control/application happen on the client. web service calls if any happen asynchronously. thats on of the advantages of using silverlight

可遇━不可求 2024-10-02 05:44:33

是的,您可以动态地将控件添加到页面,而无需往返服务器。

拖放操作也在客户端执行。

Silverlight 更像是一个桌面应用程序,它与服务器通信只是为了获取/保存数据。

在 Silverlight 中动态添加控件就像新建适当的控件类并将其插入渲染树中一样简单(例如,通过将其添加到父控件)。

Yes you can add controls dynamically to pages, without a round-trip to the server.

Drag-drop is also executed client-side.

Think of Silverlight as more like a desktop app, that talks to the server only to get/save data.

Adding controls dynamically in Silverlight is as simple as newing the appropriate control class and inserting it in the render tree (e.g. by adding it to a parent control).

信愁 2024-10-02 05:44:33

这是一个示例: http:// asd.murven.com/blog/post/2009/10/16/Silverlight-Adding-controls-dynamically.aspx

然而,我不建议仅仅为了消除这个错误而切换到 Silverlight。仅当您真正需要类似客户端的应用程序而不是真正的 Web 应用程序时。 ASP.NET 也适合动态创建控件。请记住在每次回发期间初始化服务器上​​的控件。如果这没有帮助,我建议您提交问题的描述和一些代码,以帮助我们与您一起解决问题。

Br。莫滕

Here is an example: http://asd.murven.com/blog/post/2009/10/16/Silverlight-Adding-controls-dynamically.aspx.

However, I would not suggest switching to Silverlight just to kill this bug. Only if you have a real need for a client-like application instead of a real web application. ASP.NET is suitable for dynamically creating controls as well. Please remember to initialize the control on the server during each postback. If this doesn't help, I would suggest you to submit a description of your problem with some code to help us solve it with you.

Br. Morten

乞讨 2024-10-02 05:44:33

Silverlight 中发生的绝大多数事情都不涉及回发。事实上,我想说 Silverlight 代表了一种完全不同的思维方式。每当有来自 Silverlight 的回发时,它几乎总是异步的,并且服务器不需要担心“视图状态”。在我看来,在编写 Web 应用程序时,它使 ASP.NET 看起来像个笑话。

The vast majority of what goes on in Silverlight involves no postback. In fact, I'd say Silverlight represents a completely different mindset. Whenever there IS a postback from Silverlight, it will almost always be asynchronous, and there is no "view state" that the server needs to worry about. In my opinion, it makes ASP.NET look like a joke when it comes to writing web applications.

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