Choose Enter Rather than Pressing Ok button - asp.net

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn't do the "Ok". Instead I have to manually click on Ok to Submit. How can I do by pressing Enter on my Keyboard rather than Clicking on "Ok" button after selecting the value from dropdown list. I have set the SubmitBehavior to true.

Try the solution here: ASP.NET 2.0 - Enter Key - Default Submit Button.

Assuming you're talking about a web form:
I'm no ASP.NET guru, but the default behavior of an HTML form is to submit in this case. Common causes for this are the HTML form fields not being contained within the form element, or the submit button having a nonstandard javascript function fire instead of submitting proper.
I realize that's not an answer, but I hope it might help.

using jquery you can do something like this
$("#fieldName").keypress(function(event)
{
if (event.keyCode == 13)
{
return true;
}
else
{
return false;
}
});
See more here: http://docs.jquery.com/Events/keypress

Try setting Page.Form.DefaultButton = OkButton; in your code-behind.

Related

JavaFX Combobox: handling key pressed for enter

i want to change the focus if a user press ENTER in a combobox. Firstly, i used an action-listener, but this will be also triggered when a user changes its value by pressing arrow key up or down or selecting value in the dropdown.
Therefore i thought that i could solve that by registering a key handler. But it doesn't work for the ENTER key.
Is there a way to solve my problem?
Edit:
Sorry i thought that my intro is enough.
So i have little form with some textfields and a comboBox. To increase the usability, the user only needs to press enter to switch to next field. This works great for textfields:
textfield.setOnAction(e -> {
cmbTax.requestFocus();
});
But if i register an action-listener, it would not fulfill my requirements, because it will be always triggered when value is changed:
cmbTax.setOnAction(e->textfield2.requestFocus());
So i tried a key listener, but it didn't react on ENTER, because it is handled internal before my listener would be called:
cmbTax.getEditor().setOnKeyPressed(this::handleKeyPressedForComboBox);
regards
This works for me:
setOnKeyPressed(e -> {
if (e.getCode() == KeyCode.ENTER) {
System.out.println("TEST");
}
});
In your case:
cmbTax.setOnKeyPressed(this::handleKeyPressedForComboBox);

CRM Ribbon Workbench - Hide + Button on Sub-Grid

I have a sub grid on a new entity called Issues, the sub grid is for another new entity called Cost Detail.
I have them both loaded into my solution called Issue, and have opened issue in the ribbon workbench.
What I want to do is when you are on the Issue form and can see the sub-grid I want to be able to hide the + button which is displayed. However when I have hidden this button in the ribbon workbench it also hides the add new button in the 'Associated View' therefore no records can be added.
How do I do it so that only the + button on the sub grid is hidden and not the other view?
EDIT:
In order to hide the add button, you either need to take away create privileges to the role that the user is in or you could do a hack(unsupported) like this:
function hideAddButton(){
var addButton = $('#NameOfGrid_addImageButton');
if(addButton.size())
addButton.hide();
else
setTimeout(hideAddButton, 1000);//checks every second to see if the button exists yet
}
and call the hideAddButton function on form load
There is one answer that I found. If you have a field that unique for that entity, then you can do it with a simple javascript code.
Here is steps that you must follow in ribbon workbench:
Right click the button and customise button.
Add an enable rule, in Steps section add an Custom Javascript Rule, that contains your library and function name, please make sure that default is true.
This must be in your javascirpt library :
function hideAddNew(){
if(Xrm.Page.getAttribute("yourField")){
return false;
}
else {
return true;
}
}
Add a command that contains the enable rule we created.
Add the command to button.
That's it. I test it, it is working.

ASP.NET - Enter disabled on form prevents enter (new line) in multiline textbox

I have a master page with a form:
<form id="FormMaster" runat="server" onkeypress="return (event.keyCode != 13)">
The enter key disabled is a must. However, now the enter key is disabled in textboxes as well, and that is a problem.
Is there a way I can enable enter key for textboxes inside this form?
Thanks.
Simply don't disable "form enter" using the form keypress event.
If there is more than one input/control, browsers shouldn't "submit on enter", but rather only when enter is pressed while a submit button is focused .. (which means you can use a similar approach to disable enter on the submit button or make it unfocusable in such cases).
If you must use the keypress event of the form, look at the Event Target property, and only perform the event suppression if not one of the appropriate multi-line inputs (aka textarea elements).
if ((event.target || event.srcElement).nodeName != "TEXTAREA") {
// not textarea (multi-line input), suppress as original
}

How to disable RadNumeric TextBox, but with working spinbuttons?

I have a Telerik RadNumericTextBox that has spinbuttons to increment/decrement the value. I want to prevent the user from entering their own input and to only use the spinbuttons. When I try to disable the textBox or make it readonly, the buttons are disabled as well. Is it possible to keep the buttons functional and make the textBox only for display?
I have certain attributes on this control that I need so continuing to use a Telerk RadNumericTextBox would be more convenient than using other controls.
$telerik.$($find("Numeric1").get_element())
.focusin(function(){ this.readOnly = true; })
.focusout(function(){ this.readOnly = false; });
Working on this page http://demos.telerik.com/aspnet-ajax/input/examples/radnumerictextbox/firstlook/defaultcs.aspx

Can Anyone Help me with this? Refresh update panel partially onclient side

i have a dynamically created gridview button that fires off a modal popup when clicked. I do this onclientside like so:
function openModal(btnId, v) {
deptdata(v);
// __doPostBack('<%=DropDownList1.ClientID %>', '');
btn = document.getElementById(btnId);
btn.click();
}
function deptdata(v) {
document.getElementById('<%=vendor.ClientID%>').value = v;
}
This is how the function is called in the code.
btnedit.OnClientClick = String.Format("openModal('{0}','" & GridView1.Rows(i).Cells(0).Text & "');return false;", hidden.ClientID)
I set the value of a hidden field(Vendor) but I need that value for what's in the modal popup. I have a dropdown list that depends on that newly set variable. The variable is set depending on what row was clicked. So i need to somehow just reload that popup. I have an Update Panel but I can't get that Panel to reload. I've tried __doPostback and it didn't help. any ideas how to update the panel or the dropdown in the panel using javascript?
It's not very clear from your description and the limited code you provide what it is exactly that you are trying to do and what is failing. However, the following might give you some ideas. If you provide more detail and code someone might be able to give you a better answer.
ScriptManager1.RegisterAsyncPostBackControl(Button1);
to trigger an update panel post back from js make sure you use UniqueID, not ClientID, thats a common gotcha that prevents the async postback from working.
__doPostBack("<%=Button1.UniqueID %>", "");
Personally, I have all but given up on UpdatePanels, I only use them in the most trivial cases. I prefer to have my js call an ASP.Net JSON webservice and have the on completed function render any needed changes to the html. It's more flexible, lighter and infinitely faster for pages with large grids or a lot of controls.

Resources