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
4 Answers
Reset to default 3If 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
版权声明:本文标题:c# - How to avoid page refresh on select of DropDownList - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744960628a2634630.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论