拖放调整 ASP.Net Web 部件的大小
我正在开发一个包含 ASP.Net Web 部件页面的项目。已要求通过单击右下角的字形并将 Web 部件拖动到所需的大小来调整 Web 部件的大小。当然,新的尺寸需要坚持下去。 (理想情况下,其他 Web 部件会移动并调整自身大小以适应不断变化的 Web 部件,但让我们一次解决一个挑战。)
是否有一种简单的或至少相对完善的方法来实现这一目标?我知道使用 jQuery 可以相当轻松地调整大小,但保留新的大小是棘手的部分。
I'm working on a project that includes a page of ASP.Net web parts. It has been requested that the web parts be made resizable through clicking on a glyph in the lower right hand corner and dragging the web part to the desired size. Of course, the new size needs to be persisted. (Ideally, the other web parts would move and resize themselves to accommodate the changing web part, but let's tackle one challenge at a time.)
Is there an easy, or at least relatively well-tried, way to achieve this? I know the resizing could be done fairly easily with jQuery, but persisting the new size is the tricky part.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否正在为您的 Web 部件使用 ASP.Net 个性化?如果是这样,您可以在每个 Web 部件控件中定义一个类属性(我的控件继承自 UserControl 并实现 IWebPart)来保存部件的大小。然后你可以使用你的jquery解决方案或客户端上的任何解决方案,将新的大小传递回服务器端(使用隐藏字段或其他)并将大小分配给属性(还需要在页面加载时读取属性,课程)。瞧,持久化的 Web 部件大小。
这一切都假设您已经在数据库上实现了个性化。它实际上很容易设置..使用关键字 aspnet_regsql 和个性化进行搜索。
Are you using ASP.Net Personalization for your web parts? If so, you could define a class property in each of your web part controls (my controls are inheriting from UserControl and implementing IWebPart) to hold the size of the part. Then you can use your jquery solution or whatever on the client side, pass back the new size to the server side (using a hidden field or whatever) and assign the size to the property (also need to read the property on page load, of course). Voila, persisted web part size.
This is all assuming you have implemented Personalization on your database. It's actually very easy to set up.. search using keywords aspnet_regsql and personalization.
抱歉,安,由于某些奇怪的原因,我看不到添加评论的选项,所以我不得不添加另一个答案。
支持个性化的属性可以与 Ajax 调用一起使用,但这并不容易。为了让我的工作正常工作,我必须添加大量复杂的客户端代码,并对特定的更新面板进行 __doPostback 调用。在包含可个性化属性的 updatePanel 上调用 __doPostback 应会导致 asp.net 个性化框架执行所需的代码。
Sorry Ann, for some bizarre reason I don't see an option to add a comment so I had to add another answer.
Personalization-enabled properties will work with Ajax calls, but it's not easy. To get mine to work I had to add a lot of kludgey client-side code with __doPostback calls to specific update panels. Calling __doPostback on an updatePanel containing a personalizable property should cause the asp.net personalization framework to execute the required code.