.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

jQuery modified ListBox not posting back modified values

Posted By:      Posted Date: August 27, 2010    Points: 0   Category :ASP.Net

Hi everyone,

I have an ASP.Net ListBox that I'm trying to populate via jQuery, using the following snippet:

        $("#MyList_btnAddAll").click(function(e) {
        $('#MyList_lstAll option').appendTo('#MyList_lstSelected');

The code has two ListBoxes in fact, one a "source" and the other a "destination".  As you can tell above the ListBoxes are MyList_lstAll and MyList_lstSelected.  These are rendered in the browser as <select> elements, as you'd expect.

The jQuery is working great, the items are moving from one ListBox to the other, the DOM is updated but when I submit this form (not using jQuery), the ListBoxes don't reflect this change on postback. 

I realize my modifications via jQuery aren't available in ViewState but I thought since the DOM was updated these changes would be part of the postback data?  But in the codebehind after postback the ListBox contents haven't changed.  Does anyone know what might be going on and what I can do about it?  Many thanks.

View Complete Post

More Related Resource Links

import-spweb changes some values (create date, modified...)


all my Imported items (export-spweb - >import-spweb) have today's date now.
And the creater is now mydomain\administrator.

Can I fix this somewhere ?
Maybe in a SQL table ?


'Modified By' Column gives incorrect values in an approval workflow



I have an approval workflow (working on an infopath form library) that requires approval from 6-7 users at each step (7 steps in total). With every approval, my workflow captures Date/Time and Approver's Name using Modified and Modified By column respectively and paste the details on designated columns in the form library. This way we are logging approvers name and date/time details of approval.

The logic works fine in majority of the cases but sometimes the workflow works abruptly and paste name of approvers of one step to another steps. Sometimes it also pastes  the name of the form initiator in the approvers name column. Mind you, the logic is to capture values (using modified by and modified column) when the approver is editing the column while approving it. Once the form gets approved at an initial level it cant revert back. Similarly an incremental variable (number column) has been introduced that restricts values of one step to cross over to another step and vice versa.

As soon as the initiator fills the form, it switches to read-only mode. This way even initiator cant edit the form later on.


What possibly is causing this problem? May be the form session does not time out properly and the system recogniz

Change the created and modified values of a file in SharePoint


I am trying to import a bunch of files into SharePoint from an old collaboration system we are getting rid of. The problem I am facing is the file information must be retained. For example, if the file was created 12/14/2007 by Joe, and then modified 4/10/2009 by Sue, I need to make sure that information is set in SharePoint when I add the file.
It looks like the needed properties in SPFile are "get" only.
I also tried to use a hashtable to try and force those values upon the file upload as shown in the code below, but that didn't work either.

        private static void UploadFile(string srcUrl, string destUrl)
                using (SPWeb site = new SPSite(destUrl).OpenWeb())
                    //## Put the file into a filestream
                    FileStream fStream = File.OpenRead(srcUrl);
                    byte[] contents = new byte[fStream.Length];
                    fStream.Read(contents, 0, (int)fStream.Length);
                    //## A hashtable for the file metadata
                    Hashtable metadata = new Hashtable();
                    metadata.Add("ModifiedBy", "Joe Blow");

jquery autocomplete multiple values


i got some samples and i did autocomplete using jquery , its working well for single input values

but i need to pass multiples values after one by one in the textbox. Is it possible to pass multiple

values in the textbox for autocomplete in jquery in asp.net?


Posting data to ASMX and return Object for jQuery


I am using fluent NHibernate with WebForms and I am trying to build a page where I allow a user to post a status update on their profile page and I a using a .asmx WebService to post the data to the database and then returnig a StatusUpdate instance to the page to be used by jQuery. I have a couple problems.

1) First off when I return a string from the WebService(i was testing) the textbox where the user enters their status doesnt empty the contents. And since the page doesnt refresh even if I manally clear out the textbox and put in something else, it still posts the previous status to the database again. How do I fix this?

2) Secondly, when I return the StatusUpdate Object from the Webservice I cant the results to display anything. Like I sad, Im using jQuery to make an AJX call to the WebService.

Here is my code:

User Profile Page:

Status: <asp:Label ID="status" runat="server"></asp:Label><span style="font-size:.7em;"><asp:Label ID="statustime" runat="server"></asp:Label></span><br />
<textarea id="statusBox" rows="3" cols="40"></textarea><br />
<input type="button" value="Update Status" onclick="SetStatus(); return false;

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)


Hey guys

I came across this bug using while trying to implement a sitemap

Line 147:						Panel panel = new Panel();
Line 148:						panel.Controls.Add(_viewState);
Line 149:						Page.Form.Controls.Add(panel);
Line 150:						string script = "document.getElementById('" + _viewState.ClientID + "').value = GetViewState__AspNetTreeView('" + Extender.MakeChildId("UL") + "');";
Line 151:						Page.ClientScript.RegisterOnSubmitStatement(typeof(TreeViewAdapter), _viewState.ClientID, script);

[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
   System.Web.UI.ControlCollection.Add(Control child) +8696951
   CSSFriendly.TreeViewAdapter.SaveAdapterViewState() in E:\wwwroot\ThirdParty\CSSFriendly\CSSFriendly_24242\CSSFriendly\TreeViewAdapter.cs:149
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +8901848
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +148
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +148
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +148

Info Path form when modified by using UTF-8 encoding having issues with existing 'iso-8859-1' char



I am modifying the infio path form 2007 from my state machine workflow to constantly update the status fields in the request form.

below is the method i created for the same..

private void updateInfoPathRequestForm(string xpathNode, string nodeValue)
            SPUserToken token = workflowProperties.Web.CurrentUser.UserToken;
            using (SPSite _site = new SPSite(workflowProperties.Site.ID, token))
                _site.AllowUnsafeUpdates = true;
                using (SPWeb _web = _site.OpenWeb(workflowProperties.Web.ID))
                    SPListItem item = _web.Lists[workflowProperties.List.ID].Items[workflowProperties.Item.UniqueId];

This page has been modified

I have a spin on a well documented problem.  I have several sub sites that have this issue.  Quite often when a new list item is being created, the person clicks new, types in some text and then clicks OK, they get an error that says "This Page has been modified since you opened it. You must open the page again."  If you click back and click OK again you get the same error.  You have to cancel and click new again to get around it.  This doesn't always happen, I'd say about 20% of the time.

This is not on a new page, not adding a webpart, not editing a content editor.  This is a brand new task in a task list.
This will also happen when an item is being edited.  A task is edited, click OK, get the error saying it has changed.  No other person is using the list. Again this doesn't always happen.

Any ideas?

Model Binding the values in an HTML Table back to Controller / Model


Currently, I am working with ASP.NET MVC1 and am still learning about Model Binding and how values from a View are passed back to the Controller / Model. Specifically, I want take an existing Model, create a Table and populate the Rows of the Table, allow the user to edit some fields and pass it back.

In my example, I have a Class called "Ingredient" which has 4 public accessors:  Name, Barcode, Amount, and Unit

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<MvcACE.DomainModel.Entities.Ingredient>>" %>

<% using (Html.BeginForm("SubmitOrder","MyController"))
{ %>

<% if (Model != null)
foreach (var item in Model)
{ %>
<td><%= Html.Encode(item.Name)%></td>
<td><%= Html.Encode(item.Barcode)%></

Passing values from vb to jquery


I have an asp.net page with a vb code behind file. I also have a simple menu built with an unordered list which is controlled by jquery. Basically, how do I pass a value from the vb code behind file to the jquery? At the moment im assigned the value to an asp:label  that I'm able to read in jquery, but it's a bit messy. Is there a better way of doing it?



Posting back a disabled button


Folks, I have a control which inherits from LinkButton and I'm trying to make sure that the user cannot cause mayhem by performing multiple postbacks.  That seemed an easy enough challenge, so I have this code [snippet] on the client:

ButtonClicked: function () {
    if (this._DisableOnClick == true) {
        this.get_element().disabled = 1;
        this.get_element().style.cursor = 'wait';
    else {
        alert('Posting back');

The alert is of course only there for debugging.  If the DisableOnClick value is false, then I see the "Posting Back" alert and, when I click ok, the postback occurs - all good.

If the DisableOnClick value is true, then the "button" gets disabled and the cursor turns into an hourglass - again good.  But the postback doesn't happen - not good.  I assume that the ASP client code is trying to help by preventing the postback when it sees that the link is disabled.

So, how can I either:

  • Persuade the LinkButton to postback even though it has just been disabled; or
  • [probably better] Get my client code to execute immediately after the postback code rather than before.



Saving JQuery date back to SQL Server


Hi..my web app uses lots of asp:textboxes and I can save this data back to SQL Server easily using a stored procedure..

however my JQuery datepicker uses an input textbox, how do I save the date entered into this control.

<input id="datepicker"type="text" /> back to server and can I use the same stored procedure that I use for the other data?



Modified column missing when sorting


I resently updated few document libraries on my sharepoint site.  What I did I removed "Content approval" from those libraries and now my modified and created columns are missing from the columns of the list (appear to be hidden ).  So, I need to be able to sort by these columns and I have seen many people asking about this same question but I haven't found any answer to this issue.  The columns are still there but I they dont show up in the columns of the library.  I can still create a view with this columns but i cant sort by them.

Is this a bug or is there a reason why sharepoint does this? 


Latest Records depending on Last Modified Date

Hi there,             I have to get the latest records from the table depending on Last Modified date. Table: ID  Function   Apply        Approved    Withdrawn   LastModifiedDate 1    Coding    1/1/2010   15/1/2010   21/1/2010     21/1/2010 3:58:23 1    Coding    1/1/2010    NULL           NULL           21/1/2010 4:58:23 2    Testing    1/1/2010   15/1/2010   21/1/2010    21/1/2010 3:58:23 3    Analysis  1/1/2010    NULL           NULL           21/1/2010 4:58:23   Output is needed on the basis of last modified date if same fucntion comes more than 1 time. else all other functions need which appears once in table. ID  Function  Apply      Approved    Withdrawn        LastModifiedDate 1    Coding   1/1/2010    

Attachements on a modified form for Help Desk Tempate

I changed some labels of the form of capture the Help Desk template, but the attachments functionality does not work as before to change it, it generates the following message when click on the OK button after you attach a file: Message: Object required, Line: 5797, Char: 3 Code: 0 URI: https: / / volaris01.temp.hostedexchange.mx/_layouts/1033/form.js? rev = df60y6YolDjUVbi91% 2BZw% 2FG% 3D% 3D. This only happens when I edit some labels or hide some fields from the SharePoint Designer, someone show me if I need any patch, or maybe I doing something wrong with this template? Thank you all.

Collection was modified; enumeration operation might not execute.

Hi,            i'm trying to update my dataset. I want to finad a particaular value from dataset, and bind it to exch and every record of Dataset The code i'm using to update the dataset is: Dap.SelectCommand = Cmd Dap.Fill(DS)Dim pRow As DataRow For Each pRow In DS.Tables(0).RowsField1 = pRow("StoreName").ToString() Field2 = Convert.ToDouble(pRow("abc")) + Convert.ToDouble(pRow("sds")) + Convert.ToDouble(pRow("sdczs")) - ((Convert.ToDouble(pRow("xcvx"))) + (Convert.ToDouble(pRow("xcv"))) + (Convert.ToDouble(pRow("xvc"))))Dim row As DataRow = DS.Tables(0).NewRow() row("Field2") = MarginDS.Tables(0).Rows.Add(row) DS.AcceptChanges() Dap.Update(DS) ' ================================== ' ===> Bind Values To Web Chart <=== ' ================================== WebChartControl1.Visible = True WebChartControl1.DataSource = DS WebChartControl1.SeriesDataMember = "Field1" WebChartControl1.Series(0).ArgumentDataMember = "Field1" WebChartControl1.Series(0).ValueDataMembers.Item(0) = "Field2" WebChartControl1.DataBind() Next When i tried to execute the code i got the error saying  'Collection was modified; enumeration operation might not execute.' Can you pl .help in fixing the pr

Client Object Model - cannot retrive "Modified By" field value

Hi, I am using Client Object Model to get all items from a list and display theme with "Modified By" information. Everything works nice until I start using test users. I have noticed that for user who is in Domain Admins group i have no problem for others I cannot read "modiefied by" field value. var context = ClientContext.Current; activitySPList = context.Site.RootWeb.Lists.GetByTitle("Activities") activityItems = activitySPList.GetItems(CamlQuery.CreateAllItemsQuery()); context.Load(activityItems); context.ExecuteQueryAsync( ClientRequestSucceeded, ClientRequestFailed ); All items in activityItems collection doesn't have "Modified By" fields. Do you know why and how to fix it? Thanks for your help.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend