admin管理员组

文章数量:1406060

I am working on a project in which on selecting a drop down list item the values from the database should appear in the respective two text boxes. But, alongside I am placing an image which is actually getting created based on the two values. Now on selecting the next dropdownlist item there is a page refresh and the placed image dissapears. How to I avoid the page refresh keeping in mind that the fields from the database must get displayed on the page in the two fields on select of drop down list. Kindly help! thanks... In my case, there exists a table in which there are two halfs, the left has text boxes n a button n to the right side of the table the image appears.

I am working on a project in which on selecting a drop down list item the values from the database should appear in the respective two text boxes. But, alongside I am placing an image which is actually getting created based on the two values. Now on selecting the next dropdownlist item there is a page refresh and the placed image dissapears. How to I avoid the page refresh keeping in mind that the fields from the database must get displayed on the page in the two fields on select of drop down list. Kindly help! thanks... In my case, there exists a table in which there are two halfs, the left has text boxes n a button n to the right side of the table the image appears.

Share Improve this question asked Nov 26, 2012 at 11:18 ASHAYASHAY 431 gold badge3 silver badges8 bronze badges 1
  • 1 you can disable the AutoPostBack on the dropdownlist, but you'll probably need the postback to get the data from the database into the textboxes. Unless you want to use ajax calls to do that instead. – CuccoChaser Commented Nov 26, 2012 at 11:23
Add a ment  | 

4 Answers 4

Reset to default 3

If you are using ASP.NET WebForms, you could wrap the controls which you only wants to post back inside an UpdatePanel.

Alternatively, remove AutoPostBack="true" from your DropDownList, and use javascript/jQuery AJAX to perform your database request.

Disable autopostback.

<asp:DropDownList AutoPostBack="false" ... />

Without the slightest piece of code, this will be hard to answer.

To prevent default behavior in javascript, there is this method

e.preventDefault();

Where e is your event.

Your issue is to preserve the values fetched from DB.

The easiest and safest way is to store the values fetched from database into hidden fields. This way when your page postbacks the values persists and you can use them as you wish.

Happy Coding!!!

本文标签: cHow to avoid page refresh on select of DropDownListStack Overflow