Drag-and-drop resizing of ASP.Net web part
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开发者_如何学C 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.
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.
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.
精彩评论