Validate on Button1 click, but not Button2 - c#

I have two buttons, a text box, and a combo box on a page:
The user inputs an integer to search for in the text box, and presses the Find button. A data grid is populated, the user selects a row, and clicks the Print button.
I want the Print button to validate that a selection has been made in the combo box (i.e. selectedindex is not -1). The combo box is an ASPxComboBox (DevExpress control). On the ComboBox, RequiredField.IsRequired is set to True. However, this causes the ComboBox to be validated on click of both Find AND on Print. Validation should not happen on click of the Find button.
How can I force a selection in my combobox on click of one button but not another?

On the Find button, which you don't want to trigger the validation, set the attribute
CausesValidation="false"

Related

How to Stop postBack on pressing Tab button in rad grid numeric filter?

I have set the Rad Numeric Filter's autopostback property equals to true and currentfilter function is equal to of the current Numeric column. Now when i put some text in numeric filter text box and press tab button then the page is postback automatically. How to stop this postback on pressing tab button.
<telerik:GridNumericColumn DataField="Taskhrs" HeaderText="Task Hours" FilterControlWidth="50px"
HtmlEncode="true" AutoPostBackOnFilter="true" CurrentFilterFunction="EqalTo" />
when put some value in filter text box and press enter it's working fine but when we press tab button then it also postback but i want to stop postback on pressing tab button .
Write a jQuery and find the GridNumericColumn. Now just find the press event of the Tab button and set the focus to the closest element in the Dom. (As i think the focus is not setting up properly.)
After your code of disabling the postback.
//Selects the closest element that matches your selector
$(this).closest('yourSelector');
Set the focus
$('#yourclosestid').focus();

How can I load data when I click in another box?

I have an autocomplete on my page where I use it as a search. I want to be able to select an item that appears in the autocomplete and then when the user clicks another box it will do a postback and if there is data for the one selected, it will populate the other fields for that chosen selection.
So what I am asking, is how would I go about doing a postback when the user clicks into another textbox on the screen?
Hi you could use event from textbox (TextChanged) inside this event put your code to verify if this data is correct. Don't forget put property AutoPostBack from textbox in True. This action only can be use if the data in textbox change if for example you put
My Dog
and data not exists if you change focus nothing will happen until you change the data for example
My Cat

Textbox focus skipping on pressing TAB

I have app where I have multiple textboxes and I would like to do when the user is focused in one textbox when he presses TAB button on keyboard I would like to skip the focus into other textbox which I will set.
Is there any way to do that easily? I have 20 textboxes in this form and I need it to skip from textbox1 to textbox2 to textbox3....textbox20 when press the TAB key.
First of all you have to set the tab index of each text box,
you can set either from the properties window (for each textbox ) or set by selecting the menu
view->Taborder.
you can set the tab index and by pressing the Tab key the control wil automatically transfer from 1 textbox to another.
Sounds like you're looking for the TabIndex property, which is an integer value you can assign to controls either in code or in the designer properties window:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.tabindex.aspx
See also the TabStop property:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.tabstop.aspx
Example:
TextBox1.TabIndex = 2;
TextBox2.TabStop = false;
TextBox3.TabIndex = 99;
With focus on TextBox1, pressing tab will jump to TextBox3, then back to TextBox1, and obviously TextBox2 is skipped.
in c# every Control has a property called tabStop and tabIndex
setting the tabIndex one after the other will make that when you press tab from one one textBox you'll get focus on the other
if you want a control not to get focus when pressing tab, though i'm not sure u want, but your question isn't clear on that so i didn't want you to miss it, put true in tabStop

WPF Prevent button from taking focus from any other control

I have an "On screen keypad" with some up/down/left/right/select buttons.
The select button is effectively a click and the arrow keys fire the associated up/down/left/right key.
The problem is that when selecting a combo box, I can't press the down/up buttons to navigate the items in the list. It is because the combo box auto closes when loosing focus. I can see similar problems happening with other controls, so I would like to see if there is a way to do the following.
For certain buttons (up/down/etc), when clicked, fire the click event, but don't take focus from w/e currently has the focus. This would allow the combox dropdown to stay open while pressing up/down to navigate through the items.
I have tried to set Focusable=False on the navigation buttons but the focus is still taken away from the combo box and the dropdown closes.
Any ideas/suggestions?
Thanks in advance
This isn't happening because of anything your Buttons are doing so changing their focus state won't make any difference. ComboBoxes close when you click anywhere outside of them, including empty space, non-interactive controls, other windows...

Deselect combo box when form starts up

I have form 1 and form 2.
From form 1 I have a button that directs me to form 2.
On form 2 I have Combo Box and few text boxes.
The problem is that every time I enter form 2 then my combo box is selected and when user clicks on any letter it appears in combo box.
How can I deselect this field? So user isn't pointed to this combo box at start?
And second question, how can I disable editing text from combo box completely? that the only choice user have is to pick one of 3 selected items?
Regards.
1) Set the Tab Order on the form so that the correct control is selected when the form is activated
2) To disable text entry in the combo and thus restrict selection to the defined items only, set the combo's DropDownStyle to DropDownList

Categories

Resources