Modifications in client side can't be detected in server side.

Hi,

I have 2 HTML controls in my page, that run at server, Drop Down List (Copy From), List Box (Copy To), and 1 ASPX button,

On the page load i populate the DDL, from database, 3 item added for example.

At the end of HTML page, a java script code call a JS function, that function get all items of DDL and remove the selected item, and place the other 2 items in list box, so if i have A, B, C in DDL, and A Selected, the script only place B, and C in the list box.

The population of DDL performed in the server side, the population of list box performed in the client side by java script, now when user post back the page to server, i.e. clicked the button, the DDL.items.count = 3 but ListBox.Items.Count = 0, The page show 2 items in the list view! but server detect 0 items in the listbox.

HTML for DDL, and ListBox

                <select id="Lst_From" style="width: 98%;" onchange="PreventDuplication()" runat="server">
                </select>

                <select id="Lst_To" runat="server" multiple="true" size="4" style="height: 100px; width: 98%;">
                </select>
Populate the DLL code
                for (int i=0; i < _family.Members.Count; i++)
                {
                    Lst_From.Items.Add(new ListItem(_family.Members[i].FullName, _family.Members[i].PersonId.ToString()));
                }

The Java Script Function

    function PreventDuplication()
    {
        var From = document.getElementById("&lt;%= Lst_From.ClientID %>");
        var To = document.getElementById("&lt;%= Lst_To.ClientID %>");
        //To.options.length = 0;
        for(var i=0; iif(From.value != From.options[i].value)
            {
                var NewOption = document.createElement('option');
                NewOption.text = From.options[i].text;
                NewOption.value = From.options[i].value;
                NewOption.selected = true;
                try 
                {
                    To.add(NewOption, null);
                }
                catch(ex) 
                {
                    To.add(NewOption);
                }
            }
        }
    }

 The C# code, that get items count

        void PerformCopy()
        {
            // That works great, the Lst_From populated from server, so works fine
            PersonInfo Source = PersonDataManager.GetPerson(int.Parse(Lst_From.Value));

            if (Source != null)
            {
                PersonCollection Destination = new PersonCollection();
                // Fill person collection from the destination list, only if selected!
                // Lst_To.Items.Count    always = 0, because its populated by JS
                for (int i=0; i < Lst_To.Items.Count; i++)
                    if (Lst_To.Items[i].Selected)
                        Destination.Add(PersonDataManager.GetPerson(int.Parse(Lst_To.Items[i].Value)));


            }
        }
 
Help please!
Thanks

Kind Regards

John F. Mekhail
Http://www.DominatorLegend.Co.Nr
0
FrostedCore
7/20/2008 10:48:07 PM
asp.net.client-side 24353 articles. 1 followers. Follow

1 Replies
683 Views

Similar Articles

[PageSpeed] 31

You have to re-create these items on the server side, as client-side changes (through DOM) is not persisted.

See http://forums.asp.net/t/1206587.aspx


If this post was useful to you, please mark it as answer. Thank you!
0
johram
7/20/2008 11:38:31 PM
Reply:

Similar Artilces:

Can't combine client-side & server-side
I have aspx file (with master page). I need to activate cilent-side vb script function (which is in the aspx) that gets remote IP address and resolve it's hostname. but I'm not able to send the IP' this is my code: <td>document.write(GetHostNameFromIP(<%Request.ServerVariables("REMOTE_ADDR")%>)))</td> can someone tell me what's wrong ? Seems you should write something like: <td><script type="text/vbscript">document.write(GetHostNameFromIP(<%= Request.ServerVariables("REMOTE_ADDR") %>)))</script>...

Firing both Client side event and server side event for server side button
I am having some difficulties getting this to work.. I have button_click (Asp.net) and ClientClick (Javascript).  Javascript is firing fine.  Server script is not. may be you have return return false in the in the javascript which is why its not firing server side event.You should add javascript evelt like thisbutton1.onclientclick = "functionname" Function should nopt return false. Vikram www.vikramlakhotia.comPlease mark the answer if it helped you...

client side click handler / server-side command event doesn't fire
I am rewriting an old control of mine to be more AJAX-friendly. It is a subclass of Button that disables itself when clicked, so that the user can't, say, double post a credit card payment. I have some javascript code for the prototype including this: _onClick : function(e) { if(this.get_element() && !this.get_element().disabled && this._DisableAfterClick == true) { this.get_element().disabled = true; if (this._DisabledText != null && this._DisabledText.length > 0) { this.get_element().value = this._DisabledText; } } //this.get_element().form.s...

Client side and server side
We have a application, where we have some validation on the clientside using EnableClientSideValidation. If you don't have fullscreen you can't see some of the error-messages. What we want is to jump to the place on the page where the message is displayed. One problem is that the button is a serverbutton (runat="server"). How can we accomplish this on the clientside using the same button. I have tried to use "onClientClick" and a link something like this:   <A HREF=http://forums.asp.net/AddPost.aspx?ForumID=18#form>form<...

Server Side or Client Side
Hi I'm a bit confused about this whole server side / client side thing. Are applets, embeded objects consider client side? If I have a form within my aspx page which connects to a database on the server side what is it considered? If I have some business logic written within a VB file when the client access the functions within that business logic (for example some kind of validation function) does the client browser actually downloads that VB file? Can someone suggest how to differentiate between client side and server side components within a asp.net based website?  Hi, i can&#...

What is Client Side and Server Side?
I am New of ASP.Net What we can and should do client side and Server Side? What uses? Please any one clear my doubt. Thanking YouEndendrum Priyamudan P m R Clientside is basically what a person can see and serverside is where actions get processed. that's kinda simply puyt but thats the deal, you code serverside, and the html and javascript it generates let's the users for example click a button, then serverside you have coded what should happen when a button gets clicked for example turn text red. Then the server sends a new page with red text to the client (clientside...

client-side and server-side?
hi, can someone tells me how diff is client side and server side are these two? When I tried to do validation ... I would use Javascript ... which has something like: document.forms[0] ... I think that's client side. My understanding on server side is the "form" ... like u will have <form action=".." method=post> ..... </form> ... so it will send to server ... am I on the right track? Are there any other type of server side examples? Hi, ASP.NET itself is server side. Every piece of code processed is done on a server. What comes out of this is sent ...

Server-side or Client-side
In general, I'm wondering if there are any criteria to use when choosing between using a client side element or a server side element. For example, if I'm going to put an HTML table on a page, how do I decide whether or not to use a server control?  Should the server side always be chosen or if there is not explicit server side functionality required is it better to opt for a "normal" client side table? Obviously, if there is a need for server side control the question is answered, I'm looking more at more ambiguous situations. Thanks  This is from Micros...

How can you raise server side event from client side
Let's say I have an event on server side that handles button_click. how can I raise that event from client side using AJAX. You can create a script in a string variable, and register withScriptManager.RegisterStartupScript http://msdn.microsoft.com/en-us/library/bb359558.aspx string script = "alert('ciao!')";ScriptManager.RegisterStartupScript( this, this.GetType(), "Alert", script, true );If this answers your question, please select 'mark as answer' thanks!Andrea DottorMicrosoft MVP - ASP/ASP.NEThttp://blog.dottor.net For buttons you can use JQu...

Validation Controls in .NET ( Client side or server side?)
 i have a very basic question. We have all these validation controls in asp.net ( required field, range validator and others)..my question is the required field validator is a server side control. So does that mean that it does a post back?..is it client side or server side control  The only controls that post back are buttons and other inputs where you set AutoPostback="True", such as a dropdownlist or a textbox.  Another way of posting back is using an UpdatePanel and placing a trigger in it for a specified control and/or event. All controls are considered clien...

Jscript, moving from client-side to server-side (.NET)
Hey all I’m working translating a web-app written in client-side Jscript to run on the server-side as JScript.NET. Without needing to get too specific, I am using Jscript because the original page aggregated raw data to produce statistical results (this was done dynamically based on user 'sort-by' options). The final output is an html report that can be emailed. Because this is currently being done on the client side, as the raw data grows the load-time grows as well (to the point that has almost become unusable). I’m posting here to see if anyone has any experi...

When to use client side varidation and server side varidation in .net?
In .net or classic web application we can varidate user data either on client isde or server side. How to select which side varidate to be used? Thanks! Generally, I use both client and server validation. I make sure the input is in the correct format and reasonably valid on the client, then I verify the data on the server. The extent of validation also depends on the type of data that I need to validate.Here are a few references:Validating ASP.NET Server ControlsIntroduction to Validating User Input in Web FormsClient-Side Validation for ASP.NET Server ControlsSecurity Checklist...

Can we check validation both on client side & server side?
 Hi All, Can we check validation both on client side & server side?Thanks & RegardsNeeraj  Yes, the standard asp.net validation controls already do this.Before you process any code on the server side that should have passed through validation you need to check Page.IsValid = trueThis will also catch the situation where the user has javascript disabled. yes you can check validation both the side as per your requirement.Most advantage is that if some user set the JavaScript Enabled False in the Browser settings at that time we don't worry about any validat...

How can I set client side values as server side values?
Hi, Can anyone tell me how I can get client side values such as document.referrer, navigator.appName etc... into server side scripts? There are some client side values I'd like to set as session vars and insert into the db? How do I go about this? Thanks for any pointers Davlon PS (I'm using powersite 7.1.0.300) Pass them as page parameters, e.g., http://myserver/myurl?document.referrer=whatever&navigator.appName=yadayada Then, in your server-side script, just loop through the document.value array and get these values. -- pbm_hopethishelps, Roy Kie...