开发者

DefaultButton="InsertButton" on <asp:ListView>

开发者 https://www.devze.com 2022-12-17 00:59 出处:网络
In awhen there are no rows and user e开发者_开发知识库nter values and hit Enter after last value then new row is inserted (like it should be)

In a when there are no rows and user e开发者_开发知识库nter values and hit Enter after last value then new row is inserted (like it should be) But then the Delete button of the first row become the default button for the ListView and when user hit Enter on following rows first row in ListView is deleted.

I have tried to use surrounding both the ItemTemplates and the entire ListView. But it does not help.

Does anyone know how to solve this problme?

Also do you know how to make it work for the Edit row Also do you know how to make it work for Escape key, such that it fire cancel?


You can wrap specific content in an asp:Panel control and set the default button on that control. Could you use that control to wrap your insert row, and set the insert as the default button and take the default button property off the ListView?

Alternatively, could you add a jQuery event handler to the delete button, and if the character code matches the enter key then prevent that action?

if (window.event.keyCode == 13)
{
    event.returnValue=false;
    event.cancel = true;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消