Problem with asp.net C# focus, page_load
<p>I'm really new to asp.net and have a couple of issues I'm trying to get fixed. I have some programming experience, but it is not asp.net. However, I've been able to follow the code enough to make other changes in the code to fix other issues. </p>

<p>The first is this:</p>

<p>I'm working with a form that has a calculate amount method that gets called when the user inputs a value in an amount text box. The same method gets called when the next control, number of payments, has a value. </p>

<p>So in the two controls:</p>

<pre><code>onTextChanged="ctrlName_textChanged"
</code></pre>

<p>Then in the code behind, the textchanged method does:</p>

<pre><code>calculateAmount();
</code></pre>

<p>The problem is after the amount is calculated and returns, the focus seems to get reset and the user has to tab all the way back through the form to the place they were.</p>

<p>The textboxes in question are in a panel that starts out hidden and is made visible conditionally.</p>

<p>My apologies if I have not used the proper .net terminology. </p>

<p>It looks like the same issue may be causing my second problem. When the user types in an amount and then tabs and quickly adds the number of payments, you can see the amount get calculated correctly and very shortly displays the proper total in the total amount text box. However, even though it shows for that short time, the tab order again gets reset as well as the total amount value.</p>

<p>I've looked at different methods to try and fix the focus issue. </p>

<p>In the textchanged method, I tried using something like:</p>

<pre><code>Session["myval"] = "someval";
</code></pre>

<p>Then tried to check against that in Page_Load with something like:
     if(Session["myval"] != null) {
          this.NextControl_Name.Focus();
     }</p>

<p>but it didn't ever work correctly.</p>

<p>I also tried to set a cookie in that same textchanged method using something like this:</p>

<pre><code> Response.Cookies["myval"].Value = "somevalue";
</code></pre>

<p>Then tried to check that in Page_Load using something like the previous if block above but using Request.Cookies["myval"] as the source.</p>

<p>Is there a good reference with some really clear code samples I can look at for this type of implementation?</p>

<p>Thank you in advance, </p>

<p>C.</p>
