回复 12楼simonshen的帖子
我目前的解决方法是在页面添加 HiddenField ,记录每次 keyDown 事件按键,然后赋值给 textbox。不过,有个缺陷,keyCode 为数值型,我还没有找到把数值转换为 char 的方法。把方法提供给楼主:
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title></title>
- <script language="javascript" type="text/javascript">
-
- function funkeydown() {
- for (var i = 0; i < 3; i++) {
- for (var j = 0; j < 4; j++) {
- FpSpread1.SetActiveCell(i, j);
- FpSpread1.Clear();
- }
- }
- var textbox = this.document.getElementById("Text1");
- textbox.focus();
- //赋值
- var keepwords = this.document.getElementById("HiddenField1");
- textbox.value = keepwords.value;
- }
- function keepwords() {
- //记录按键值
- var keepwords = this.document.getElementById("HiddenField1");
- keepwords.value += keepwords.String();
- }
- </script>
- </head>
- <body onkeydown="keepwords()">
- <form id="form1" runat="server">
- <div>
- <FarPoint:FpSpread ID="FpSpread1" runat="server" BorderColor="Black" BorderStyle="Solid"
- BorderWidth="1px" Height="200" Width="400">
- <CommandBar BackColor="Control" ButtonFaceColor="Control" ButtonHighlightColor="ControlLightLight"
- ButtonShadowColor="ControlDark">
- </CommandBar>
- <Sheets>
- <FarPoint:SheetView SheetName="Sheet1">
- </FarPoint:SheetView>
- </Sheets>
- </FarPoint:FpSpread>
- <input id="Button1" type="button" value="button" onclick="return Button1_onclick()" />
- <input onkeydown="funkeydown()" id="Text1" type="text" />
- <asp:HiddenField ID="HiddenField1" runat="server" />
- </div>
- </form>
- </body>
- </html>
复制代码 |