質問

I am trying to implement a KeyDown event for a textbox in Visual Web Developer. I am using C#. I know how to do this in a windows form but the technique isn't portable to VWD. I want to capture the text in the textbox when the user hits Enter.

Any advice is appreciated.

Regards.

役に立ちましたか?

解決 2

Actually the textChanged method waits for the Enter key to be hit.

他のヒント

Sounds like you may want to read up a bit on Web forms in general. A quick summary: Since web pages are all client side, you have to explicitly tell it when to talk to the server where all the major lifting takes place.

So you have the html form tags:

<form>
</form>

and all important text boxes and other form controls go between. Then you need a submit button which under normal circumstances is the only way to submit the form to the server for processing. (The "enter" key activates the submit key also.). Submission always either reloads the page or causes a move to the next page, depending on the actions specified.

ASP.NET does take care of a lot of page events and such for you. as you have probably noticed by now, though, when you right click a text box and look at the available events, you only have a few, such as "textchanged". This is because anytime you do not actually submit a form to the server, you need AJAX to do a call to the server for you while not reloading the page. the "textchanged" event on a textbox is still going to be AJAX driven - it's just the Microsoft has built it in for you. You will want to look at either jQuery or the ASP.Net AJAX libraries.

You say you want to "store" the result - is it to generate new behavior later on the page? that's AJAX. Is it for longevity while the entire application is worked through? That can wait until the submit.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top