Last post May 19, 2011 07:38 PM by Wozer
May 11, 2011 04:47 PM|Wozer|LINK
I am having an odd issue with onblur. Every time I click on the textbox that has the onblur function, it fires, even though I have not lost focus
the HTML markup looks like this:
<asp:TextBox id="txtDescription" runat="server" TextMode="MultiLine" Width="450px" Height="150px" onblur="copyDescription();"></asp:TextBox>
My onblur does change the focus to another textbox, but it shouldn't even execute to cause that to happen until I lose focus, but for some reason it is:
The onblur function looks like this:
if (document.getElementById(chkboxAddNote).checked == 1)
DesBlurVar = true;
window.event.returnValue = false;
And the onFocus for the txtNoteDescription looks like this:
Every time I Tab or click on the txtdescription Text box, I get an Alert of Test. Does anyone have any ideas why my onblur is not firing correctly?
May 11, 2011 06:15 PM|rpgivpgmr2|LINK
After adding all the components to a blank form I do not get the same results.
It is possible if you simply close and reopen your project the problem may disappear as at times through continuously
compiling and running multiple times the programmers IE gets corrupted. If you still have a problem, post your HTML side code.
May 12, 2011 02:47 PM|Wozer|LINK
I have tried restarting the project etc but I still get the issue. I posted the HTML to the Description Control in the first post, do you need more than that?
May 12, 2011 02:56 PM|Dhaval Tawar|LINK
Is your function calling on another controls onblur();
Just try this scenario:
1 Don't put focus on any of the control when your page is loading
2 Just click on the textbox which contains issue.
Is it still calling that function?
May 12, 2011 03:14 PM|Wozer|LINK
If I do that, the Alert does not show up until the Description field loses focus, so working as it should.
May 19, 2011 04:34 PM|Wozer|LINK
I have finally gotten around to doing more testing on this issue and I think I figured out the problem. In my code behind, I have a Sub for txtQty TextChanged, that does some math and then fills out some disabled fields with numbers.
As far as I can figure out, a user enters a quantity, hits tab, the focus goes to the Description, then the TextChanged event fires, moves focus off of the Description, firing the OnBlur event.
Is there any way to have the Tab not go immediatly to the Description field, but instead fire the Textchanged sub and then go to the description field? I guess Intercept it in a sense?
May 19, 2011 05:28 PM|rpgivpgmr2|LINK
I would take all these out of functions first:
Let the user move focus by tab or mouse. If you want your functions to do focus the page will have to trap all keypresses and determine if the tab key was pressed and if no, not move focus.
May 19, 2011 07:38 PM|Wozer|LINK
I think that is what I am going to have to do, I think there is too much stuff that needs to happen, with calculations that I cant have it making all these focuses all over the page.
Thanks for your help.