admin管理员组文章数量:1310502
i am working on a asp web app in this application when customer logged in then his/her
personal details displayed in form fields (e.g. full name in name box ,age in age box etc) for getting data first i fetch the data from ms sql then assign them to ICustomer interface properties this interface is implemented by customer class.
And we also have a update button on customer information page so if without changing any information if a user click on update then unnecessary it will go to server and e back and the same data updated in database,so what i am trying to do is to just detect whether something changed in customer form then only update functionality should work.
i have two option
- just use Java script and detected the text change then unable update button.
- make a temporary reference of ICustomer and pare it to the older when then process by making something true or false.
so please suggest me the best approach for it or any other method.
if question is unclear then just ment on it i will explain more.
i am working on a asp web app in this application when customer logged in then his/her
personal details displayed in form fields (e.g. full name in name box ,age in age box etc) for getting data first i fetch the data from ms sql then assign them to ICustomer interface properties this interface is implemented by customer class.
And we also have a update button on customer information page so if without changing any information if a user click on update then unnecessary it will go to server and e back and the same data updated in database,so what i am trying to do is to just detect whether something changed in customer form then only update functionality should work.
i have two option
- just use Java script and detected the text change then unable update button.
- make a temporary reference of ICustomer and pare it to the older when then process by making something true or false.
so please suggest me the best approach for it or any other method.
if question is unclear then just ment on it i will explain more.
Share Improve this question edited Dec 28, 2011 at 3:17 John Saunders 162k26 gold badges251 silver badges402 bronze badges asked Dec 28, 2011 at 2:43 PeeyushPeeyush 4,83817 gold badges66 silver badges92 bronze badges 2- 1 You can write JavaScript code that make note on changes and pass this information when you submit a form. – KV Prajapati Commented Dec 28, 2011 at 2:51
- Anyone have an answer to this question without javascript? I am having the same issue and .OldValues is always null in the ItemUpdating method. I cannot pare oldvalues with newvalues. – Fandango68 Commented May 14, 2014 at 3:38
5 Answers
Reset to default 5If you're using the formview or detailsview control in your asp webpage, then you can use the OldValues property of the forms's itemupdating event to pare the values before posting to your database. I believe the form's viewstate must be enabled for this to work.
protected void myFormView_ItemUpdating(object sender, FormViewUpdateEventArgs e)
{
// Access the old values
e.OldValues...
Here's a full example using the detailsview.
JavaScript may help you, but it's very unreliable. I say go with the second option. Store the ICustomer
object in a Session variable and pare it with the new one.
If you're using TextBox
controls, one option is to use the TextChanged
event to detect changes.
You should go to 2nd option if the size of your object is not very large as you have to store the old object before paring to the new object of Icustomer to detect any changes. Otherwise use javascript to detect the changes on the text fields. but as you know its not very much reliable.
the main problem with the Javascript option is that what if user changes value and again change to it's previous state in that case also it'll shows value changed.
本文标签: chow to check that any form field data is changed or notStack Overflow
版权声明:本文标题:c# - how to check that any form field data is changed or not? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741822033a2399423.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论