Drag and Drop in ASP .Net? - c#

What is the simplest way to integrate drag and drop functionality?
I will have, for example a list of cases, and a list of employees and I will need to assign a case to one or more employees (among other things).
It looks complicated to do this type of task.
Is there a library or something that simplifies this?
How is it normally implemented?

Yes, use JQuery and JQuery UI, which has a draggable plugin and droppable plugin to configure this. There is nothing inherently built-in to ASP.NET.
To enable dragging, it's as simple as $( "#draggable" ).draggable();, where the #draggable is the ID of the element to drag. You can also customize the options for when dragging can be enabled, etc.

Related

Best resource to learn How to Create AJAX enabled User Controls

In our project, we use lot of User Controls. None of them supports AJAX. We use UpdatePanel for partial page rendering. There is no proper client side functions for the controls.
I used to create normal JS functions in the ascx page itself. I guess it is not the standard way to add client functionality to a User Control. However i can achieve all the things which i required , with out using any such standards. But when considering the maintainability, it is tough & it is hard to make changes & not scalable.
So i want to learn the proper way to create AJAX enabled User Controls. Just like how Telerik & other 3rd party controls create User Controls. What is the recommended way to create such controls by Microsoft.
Could you be more specific about the problem with Update Panel??
To use inbuilt ajax,
1. You need a ScriptManager
2. Put all necessary controls within Update Panel
Since you are using User Controls, its better to add ScriptManager in the main page where the User Control is added. Otherwise it might give an error saying multiple ScriptManager found.
UpdatePanel uses AJAX and is easy to use, however, if you want true client side controls, i.e. only call the server when you need too, then it's probably best to look elsewhere.
If you want to write your own controls, I'd recommended reading about some JavaScript design patterns, specifically the module pattern. If you have decent JavaScript skills, it's extremely easy to create controls with the help of jQuery - may as well make it a jQuery plugin. You might want to check out some client side MVC/MVVM frameworks like AngularJS or Knockout might be enough, because at least they'll help you with data bindings so it's less painful to manage the data on the client side and get it back to the server.
But, unless you're doing some that no one else has done before, why not use some existing controls by Telerik or DevExpress for example?
Example of module pattern (there's a bunch of different ways to do module pattern, this is just one):
var myModule = {
/* PROPERTIES */
prop1: 'sdfsdf',
prop2: 123,
/* FUNCTIONS */
func1: function () {
alert('!!!');
}
}
/* example use of module */
alert(myModule.prop1);
myModule.func1();
You'll also need to have a good understanding of events in JavaScript. For example, if you wanted to create a client side grid (there's millions already available for free), you'd need to handle click and text changed types of events. i.e. to handle paging, sorting, filtering and any other feature you might want out of your grid.
Edit: just created a basic JSFiddle to give you an example of a really basic client side control using a jQuery plugin. It doesn't work perfectly, but thought it might give you an idea of where to start if you wanted to try making your own controls.
http://jsfiddle.net/pwqmenwx/1/

How to create a Dropdown button in asp.net c#?

Does anyone know the name of the property in which it look alike button
but once if we keep the mouse pointer
on it then it will show like dropdown
list options.
I want to use that in my asp.net
project.
There is no out of the box control as such. It is an effect achieved either using javascript or CSS
Take a look at this example
http://demos.9lessons.info/DropMenu/MyDemo.html
You should also search for jquery plugins for this. Though you will get readymade code for it but it will surely not be a server side control. You have choice of either creating a user control or just use it as it is.
unfortunately there is no such control out of the box in asp.net. you might want to look at third party controls or do some css magic.
Something like that maybe a standart one(1) .But I can recommend you to use telerik if you are using it already here is a example (2)
Example2
Example2

Create a list like the outlook 2010 inbox

I want to create a control that lists items, uses a collection of text and images in each item, can be scrolled though, titles given if re-ordered and can be selected.
The best example of this would be Microsoft Outlook 2010 inbox view with right reading pane.
I was hoping there would be something in the toolbox I could re-arrange to fit by needs? or would I have to build something myself? which would be a good challenge, but as I've not done this before I would like to avoid if I can.
There is no .Net FW control out of the box for you. Either look for open source control / build on your own. FYI: I know this can be easily done in WPF world though.
also check out TreeView and Custom TreeView for basic starters..
It would be easy to re-create if you didn't need it to be ordered. For an off the shelf solution that you may be able to customize to your liking you should check out the DataTables plugin for jQuery. http://datatables.net/

treeview in asp.net

I want to use a treeview control in my asp.net project and when i drag and drop anything, it should update database. and there should be sort, when I change the sort when I drag and drop, the order column should be changed at the database.
(It is clear that treeview will get the items from database.)
I would search for examples of this via google to see what options are available with the standard .NET components, and 3rd party components (commercially purchased and jquery style plugins) See which one best fits your need and have a go at implemneting what you need. If you have further problems, let us know.

Multiple selection in a TreeView

I am using a Windows Forms TreeView control in my program. I would like to allow the user to select multiple nodes at the same level by dragging their mouse pointer around (also called a "lasso" selection). I don't think a standard TreeView allows that.
My question is what would be the best way to achieve this? Do I have to write custom selection behaviour of my own in perhaps a custom or derived control? Where do I start?
I don't need a detailed explanation. Just a small nudge in the right direction.
This is not going to be easy to do with a standard WinForms TreeView control. The TreeView control only supports single selection per tree. It is not possible to simultaneously select multiple nodes in the tree.
In order to get this behavior you would likely end up needing to create a very similar class to TreeView which allowed for multiple selection. Another option is to derive from TreeView and enable multiple selection by overriding specific behaviors. Here is an article on how to do the latter.
http://www.arstdesign.com/articles/treeviewms.html
Consider implementing multiple selection in a control that supports multiple selection like listview. If you follow standards that most Windows users understand you'll end up with a solution that is easier to implement and easier to use.
If you really need something more elaborate you might need to consider developing a custom control.

Categories