Javascript DOM Manipulation - User To Drag "li" Elements From One List To Another
Jul 7, 2010
I have an aspx page with a set of controls. A small JS script written on top of jQuery allows the user to drag "li" elements from one list to another. What I would like now is for my C# code to be able to figure out which items the user has placed in which list after the page is posted back to the server.
I have an asp.net page with several list boxes. I would like to include some javascript on the page that allows a user to drag individual list elements from one box to another. On a normal web page, the script to do this is reasonably simple, however, with the element IDs generated by ASP.NET, I don't know what identifiers to have my script look up?
I have...a dynamic populated select box several input boxes a submit button form fields are loaded initially using cookies several dynamic populated divs
I want... start loading the content of my DIVs after all FORM elements have been loaded completely (= filled with data, select boxes are populated)
I am developing small social networking site using asp.net & c#.I want to display friend list for each user. How can I do this task using java script? or there is any other way to do this task?if possible then show some demo code or example.
I have the same problem as Simon in this post. He found out some sort of a solution, but it does not work for me. Please, could someone explain me what is going on in this answer or advice me something else. PS: there is an example on the asp.net site which doesn't work exactly the same way as my reorder list... (click view a demo) The solution that is suggested here adds these few lines to web.config:
[Code]....
Perhaps I just need to change something to make it work... but I don't know what. For example I have no idea what the ScriptResource.axd is supposed to be. My code: .aspx file
[Code]....
and the code behind
[Code]....
I load the data to the List collection from the page_load event but that works fine. The data binding works as well. The problem is in that the items cannot be reordered -- during the reordering, the sort value doesn't change and the list doesn't update.
In my application(asp.net and c#) I need to drag and drop icons from a list to preview section.And also need to insert the new position into the db. And delete it from db if drag and drop it from preview section into the icons list. a method to do this using jquery/ajax.
I am using a Reorder list. I had a requirement that i have to drag a record from the reorder list to another control(may be list control or grid view). Is it possible like that?
I'm using a reorderlist (Ajax Control Toolkit Release 4.1.40412.2) inside a scrolling div (class="reorderListDemo" style="overflow:scroll; height:225px; width:1300px; table-layout:fixed; text-align:left;"). When the height of the reorderlist is greater than the height of the div, the div will automatically have a vertical scrollbar. The problem is that when i scroll down to drag an item from the bottom of the reorderlist, the reorderlist does not work properly. The drag image and the drop target does not correspond to the item i want to move.I've attached a copy of my css file:
In my Page_Load() event, I'm calling a Sub (in a module UserMenu.vb) that reads an XML file which has the user menu entries. The final menu should be an <ul> with several <li>, some of them with anidated <ul> within. As I understand, I may use a asp:Panel in my page to position a container for this elements I read and in this sub I try to add them using new BulletedList and new ListElement BList.Items.Add(LItem)), but when I get to Panel.Controls.Add(BList) it throws an error that says BList should be inserted in a Form. Why? Aren't they just <ul> and <li>? What other alternative I have to create <ul> and <li> in a specific part of my page?
As I iterate through a DataTable object, I need to check each of its DataRow objects against the items in a generic string List. I found a blog post using the List's Find method along with a delegate, but whereas that example has a separate class (Person), I'm attempting something like the following using an instance of the string object:
// My definition of the List object. List<string> lstAccountNumbers = new List<string>(); ... // I populate the List via its Add method. ... foreach (DataRow drCurrentRow in dtMyDataTable.Rows) { if (lstAccounts.Find(delegate(string sAccountNumber) { return sAccountNumber == drCurrentRow["AccountNumber"]; }) { Found_DoSomething(); } else { NotFound_DoSomethingElse(); } }
However, with this syntax I'm receiving "Cannot implicitly convert type 'string' to 'bool'" for the if block. what I'm doing wrong and how best to accomplish what I'm trying to do?
I want to develop a web form where I have a list of elements, so I want to drag a single document into an image (ex. trashcan icon, favorites icon, news icon, etc).
I read some samples of panel dragging, but this is not what I am looking for.
I have a web form that contains a usercontrol and I would like to be able to access the html elements within the usercontrol from the form page using javascript.
I had a look around with firebug and found that the tags in the usercontrol render with clientids like usercontrolid_myelement. I'm guessing that something like this might work:
Assume you have a page in ASP.NET where it makes sense to use JavaScript/jQuery to modify the DOM with values that will eventually be read by the server on submit. For example, you have a form that allows end users to add/remove objects (like dependents on a health insurance form or assets on a loan application). What are some ways to ensure that these items are detected and retrieved by the server once the information is submitted?
I've tried a few things that work, but none of them seem perfect so I wanted to see what the community had to offer. Also, I'm not looking for suggestions that avoid dynamic DOM elements (like use a Wizard, etc.). I'm specifically trying to improve my technique with dynamically created DOM elements.
So I have a dropdown setup on the page called ddlVehicleType that is populated from a store. This method gets called when another dropdown is changed, and it's supposed to remove all items from the aforementioned store, re-add them as needed, and then populate the dropdown with the new values. It's doing everything it's supposed to EXCEPT clearing the store before it re-adds the values, so the result is, when I switch, I'm getting what it used to be PLUS the new values that should be in there by themselves. Here is the weird thing though, when I switch back, the values are removed without re-adding anything. Can anyone tell me what I'm doing wrong? Method is below:
function filterVehicleTypes() { var masterStore = Global.getComponent("vehicleTypeStore").getStore(); var Source = Global.getComponent("ddlValuationSource").getRawValue(); var isIncuded = ''; var IncludeFlags = ''; if (Source == undefined || Source == null) Source = ''; Global.getComponent("ddlVehicleType").getStore().removeAll(false); masterStore.each(function(rec) { switch (Source.toUpperCase()) { case 'KBB': if (rec.get('Code') == 'KBB') { Global.getComponent("ddlVehicleType").store.add(rec); } case 'NADA': IncludeFlags = rec.get('MiscCode1'); if (IncludeFlags != null) { isIncuded = IncludeFlags.substr(1, 1); if (isIncuded == 'Y' && rec.get('Code') == 'NADA') { Global.getComponent("ddlVehicleType").store.add(rec); } } break; default: IncludeFlags = rec.get('MiscCode1'); if (IncludeFlags != null) { isIncuded = IncludeFlags.substr(0, 1); if (isIncuded == 'Y') { Global.getComponent("ddlVehicleType").store.add(rec); } } break; } }); }
in an aspx pege, on Page PostBack we generally get thsoe control that were created either in aspx or code behind (dynamic controls ). But in jQuery its common practice to craete new set of controls on the fly. Supose i have created 10 spans with some id and text . So, can we get these spans on server side on Page PostBack ?
Here is my problem. I have on multiple occasions downloaded jQuery UI and tried to use it. What happens, though, is that in the examples provided in the download the UI elements look great, but in my pages when I try to use them all the formatting and style stuff is messed up. Here is an example of a date picker:
For my page (an '.aspx' page, if that makes any difference) I have all the images in the image folder one level below the css file, just as it is in the example folder, and the script files are all together in another folder. Is there something I need that I don't have. I shouldn't need the "demo.css" file, should I? Is there a special naming convention for items in the form of the site? Is there some special way that I need to have the folders/css files/source scripts set up, like a certain folder configuration, to make it work? Kind of lost on this one. Probably a really simple fix, but I'm pretty new to using this.
I am trying to re-order the jqgrid rows using only one specific column. Currently, the rows can be re-ordered by any column. I have it setup like below:
jQuery("#list").jqGrid('sortableRows', { update: function (ev, ui) { SaveRowSorting(); } });
But the above code allows the rows to be re-ordered by all columns, however we want to restrict it to only one column. E.g, if we have 3 columns in a row. Then, we want the row to be re-ordered by only column1 and it shouldn't allow row sorting using the other two columns.
I have an UpdatePanel with a repeater in it that is re-bound after a user adds an item to it via a modal popup. When they click the button to add a new row to the repeater the code-behind looks something like this:
protected void lbtnAddOption_Click(object sender, EventArgs e) { SelectedOption = new Option() { Account = txtAddOptionAccountNumber.Text, Margin = chkAddOptionMargin.Checked, Symbol = txtAddOptionSymbol.Text, Usymbol = txtAddOptionUsymbol.Text, }; Presenter.OnAddOption(); // Insert the new item RefreshOptions(); // Pull down and re-bind all the items mpeAddOptionDialog.Hide(); // Hide the modal // ... Make call to jQuery scrollTo() method here? }
This works fine and the new row will show up quickly via the UpdatePanel. However, there are often hundreds of rows and where the new one is added is based on the current sorting column used. So, I wanted to take this as a chance to use the sweet jQuery ScrollTo plugin. I know that if I give it the ID of my overflowed container div and the ID of an element within it, it will smoothly scroll straight to the users newly added row. However, there are two problems:
I need to find the appropriate row so I can snag the ClientID for it. I need to execute the jQuery snippet from my code-behind that will cause my newly updated repeater to scroll to the right row. I've solved #1. I have a reliable method that will produce the newly added row's ClientID. However, problem #2 is proving to be tricky. I know I can just call ScriptManager.RegisterStartupScript() form my code-behind and it will execute the JavaScript on my page.
The problem I'm having is that it seems that it is executing that piece of JavaScript before (I'm guessing) the newly refreshed DOM elements have fully loaded. So, even though I am passing in the appropriate jQuery line to scroll to the element I want, it is erroring out for me because it can't find that element yet. Here is the line I'm using at the end of the method I posted above:
{"d":{"key1":"value1",2":"value2"}}s there any way of accessing the keys and values (in javascript) in this array without knowing what the keys are?The reason my json is structured like this is that the webmethod that I'm calling via jquery is returning a dictionary. If it's impossible to work with the above, what do I need to change about the way I'm returning the data?
Public Function Foo(ByVal Input As String) As Dictionary(Of String, String) Dim Results As New Dictionary(Of String, String) 'code that does stuff Results.Add(key,value) Return Results End Function