当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - Update Database on textchange

问题描述:

In an ASP.NET webform, I have 3 TextBoxes, each linked to a different SQL Database Table. Now I want to store data into table when Textbox Change event occurs. I can do successfully with make Update Query in TextBoxChanged event. Now What I want is when this update operation going on I dont want it to make interrupt my page and other operations I want to perform. I use an Asynchronous Postback from the TextBoxChanged event.

The problem that I am having with this is:

When I change one TextBox and click on another TextBox, and hit "backspace" inside that textbox, the page reacts as if it was a browser back button-click, and redirect to other page.

I hope you can understand the question I want to perform TextBoxChanged and handle the asynchronous postback without interrupting other operations.

网友答案:

You will have to use jQuery for the capturing of the textbox changing. However, you cannot connect directly to onchange as the changed value is not stored until after the event. You could probably tie to the blur event if you only want to capture when the user changes and leaves the textbox, though. Otherwise, you will have to use a timeout to continuously check if the value has changed ( Jquery: how to detect a textbox's content has changed )

Within that event, you should use AJAX to make the save calls for persisting the value.

分享给朋友:
您可能感兴趣的文章:
随机阅读: