Forum  Commercial Foru...  Commercial Foru...  OnValidating issue
Previous Previous
 
Next Next
New Post 4/19/2012 3:38 PM
  infotrac
82 posts
No Ranking


OnValidating issue 

Hi,

I have a control that inherits from MaskedTexBox and I override OnValidating on it. If validation fails, I'm setting e.Cancel to true within OnValidating in order for the focus to stay on that control, but the focus still leaves the control. What can be an issue here? When debugging, I see, that OnValidating seems to get executed.

Alex

 

 
New Post 4/19/2012 5:06 PM
  palli
14295 posts
1st Level Poster




Re: OnValidating issue 

Hi Alex,

This on is already reported in a tracker entry here. This is a derivative entry, and the main one can be found here.

Palli

 

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 5/11/2012 3:54 PM
  infotrac
82 posts
No Ranking


Re: OnValidating issue 
Modified By infotrac  on 5/11/2012 6:55:11 PM)

Hi,

Maybe you're already aware of that one, but I just wanted to add something related to this OnValidating and setting e.Cancel to true issue. If I set e.Cancel to true inside the OnValidation routine for a control, then all subsequent events are executed not on the control, that appears to have focus on the screen, but actually on that control in which I have set e.Cancel to true! It may be hard to understand this from my explanation, I guess. So, let's say that I have two textboxes: textBox1 and textBox2. I do some validation inside textBox1 OnValidating and set e.Cancel to true there. Then I click inside TextBox2 and this should trigger TextBox2's OnEnter and OnGotFocus routines to be executed, right? But what really gets executed are respective routines in textBox1 still, so in this case textBox1.OnEnter and textBox1.OnGotFocus are executed, although, I clicked inside another control on the form and the focus is in that control on the web form. Hope this helps!

Alex

 
New Post 5/12/2012 9:31 AM
  palli
14295 posts
1st Level Poster




Re: OnValidating issue 

 Hi Alex,

This is indeed a very logical behaviour and the correct one. Same behaviour will be seen in Windows Forms.

To understand why, then by setting e.Cancel = True inside the TextBox1.Validating event handler you are stating that Focus should not leave that control, so the control is entered again and those events fire as a result of that. You can argue that Enter and GotFocus should not fire on any control in this context, but this is the Windows Forms behaviour and it's replicated correctly in Visual WebGui.

I did however find a small problem there, as in this test, GotFocus did also fire on TextBox2. It should not do that as focus is to stay within TextBox1 because of e.Cancel = True setting. I opened a new tracker entry on that subject. Please view it here and follow up on our progress.

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
Previous Previous
 
Next Next
  Forum  Commercial Foru...  Commercial Foru...  OnValidating issue
.NET HTML5 Web, Cloud and Mobile application delivery | Sitemap | Terms of Use | Privacy Statement | Copyright © 2005-2012 Visual WebGui®       Visual WebGui weblog on ASP.NET Gizmox Blog Visual WebGui Group on LinkedIn Visual WebGui updates on Twitter Visual WebGui Page on Facebook Visual WebGui YouTube Channel Visual WebGui Platform News RSS