?
Solved

Field data lost after postback.

Posted on 2007-08-08
4
Medium Priority
?
213 Views
Last Modified: 2013-11-26
I am working on an application using a combination of asp.net 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?
0
Comment
Question by:jfsedlar3rd
  • 3
4 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 19654377
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.
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 2000 total points
ID: 19654406
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.

0
 

Author Comment

by:jfsedlar3rd
ID: 19654515
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.
0
 
LVL 63

Assisted Solution

by:Zvonko
Zvonko earned 2000 total points
ID: 19654585
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.



0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…
Suggested Courses
Course of the Month16 days, 20 hours left to enroll

862 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