Field data lost after postback.

Posted on 2007-08-08
Last Modified: 2013-11-26
I am working on an application using a combination of and javascript. I have a text box that populates based on a double click event being caputred via javascript for a list box. I understand the problem being that the javascript is happeing on client side so the data is not posting back to be stored in my session state. What is the best way to deal with this situation?
Question by:jfsedlar3rd
    LVL 63

    Expert Comment

    Generaly are ONLY selected options sent on postback to the server. So if you want to have the new options on server side you need them to be selected before submited.
    LVL 63

    Accepted Solution

    Here a short example:

    <form onSubmit="opt=this.yourSelectElementName.options;for(var i=0;i<opt.length;i++)opt[i].selected=true;">

    If you have more select elemts on the form then do the job in a function that you cal in the onSubmit event handler.


    Author Comment

    My fault i did not describe the root problem. The problem is the text box value is being cleared. So the user double clicks on options in a list box that selected option populates a text on the form, then the user saves and the data in the text box is cleared after page refresh.
    LVL 63

    Assisted Solution

    Then it is a simple html problem that you did NOT define the ASP or ASPX side value for that textbox. It is submited and you do not reuse it.

    Second problem could be that those textbox is outside the form and is not submitted on postback action.

    Third problem is that you have perhasp set the textbox attribute to DIABLED. The disabled elements are not submited to server.


    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now