UpdatePanel does not start when I press enter

I have a panel with several text fields and a submit button, as well as an update panel that will be activated when the button is clicked.

If I press the button, it will be ok. However, if I click on the control, it returns the whole page.

I set the button as the default button in the panel, but it still returns the whole page. Any ideas?

+3
source share
2 answers

Setting a single button on a panel by default is always a bit complicated. I saved the method in a shared library just for this problem:

public static void EnterOnKeyDown(WebControl targetControl, WebControl controlToPress)
{
    targetControl.Attributes.Add("onkeydown",
        "if(event.which || event.keyCode){if ((event.which == 13)" +
        "|| (event.keyCode == 13)) {document.getElementById('" +
        controlToPress.ClientID + "').click();return false;}} else {return true};");
}

You can place this method anywhere and call it like this:

EnterOnKeyDown(someTextBoxInYourPanel, yourSubmitButton);

javascript , .

+3

UpdatePanel :

ChildrenAsTriggers = True UpdateMode = Always

, , , , - .

0

Source: https://habr.com/ru/post/1719520/


All Articles