小三泼粪运行游戏以后会有一个上下左右的方向键,这个可不可以消除掉?怎么消除?

键盘方向键移动出现的新问题!
& & 在各位大大的帮助下,使用方向键自由移动的脚本终于能用了。我联机在其他机器上测试,却移动不了。我把其他机器上的浏览器设置为允许脚本运行,就能动了。但是后来我添加了利用CssStyle中的hidden,将GridView的各列根据需要隐藏或显示的的功能后,又出现了新的问题。最后面的代码4是键盘移动方向键的脚本!
问题1:遇到下面代码1中的那两列会出现如图1提示的错误,我猜想,大概是因为这两列没有转换为模板的缘故吧?于是我把它们转换为模板,错误依旧如图1,该怎么改呢?
----------------------代码1--------------------
&asp:BoundField DataField=&Column1& HeaderText=&序号&
ReadOnly=&True& SortExpression=&Column1& ItemStyle-HorizontalAlign=&Center& ItemStyle-VerticalAlign=&NotSet&&
&HeaderStyle Font-Size=&Smaller& /&
&ItemStyle Font-Size=&Smaller& /&
&/asp:BoundField&
&asp:BoundField DataField=&PRID& HeaderText=&ID号& InsertVisible=&False&
ReadOnly=&True& SortExpression=&PRID& &
&HeaderStyle Font-Size=&Smaller& /&
&ItemStyle Font-Size=&Smaller& /&
&/asp:BoundField&
--------------------------图1-----------------------------
问题2:我前台使用了代码2,后台使用了代码3,利用CheckBoxList的选项来隐藏或显示GridView的某列,这样可以顺利实现隐藏或显示列,但按方向键会出现如图2所示错误,又该如何修改呢?
--------------------代码2--------------------- &
&style type=&text/css&&
.hidden {display:}
.visible{display:}
后台使用了
--------------------代码3-------------------
protected void HiddenOrInline()
for (int i = 0; i & CheckBoxList_All.Items.C i++)
if (CheckBoxList_All.Items[i].Selected == true)
GridView_Search.Columns[i].HeaderStyle.CssClass = &inline&;
GridView_Search.Columns[i].FooterStyle.CssClass = &inline&;
GridView_Search.Columns[i].ItemStyle.CssClass = &inline&;
GridView_Search.Columns[i].HeaderStyle.CssClass = &hidden&;
GridView_Search.Columns[i].FooterStyle.CssClass = &hidden&;
GridView_Search.Columns[i].ItemStyle.CssClass = &hidden&;
---------------------图2------------------------------
-------------------------------代码4(方向键移动 脚本)-------------------
&script type=&text/javascript&&
function enter(obj) {
var tr = obj.parentNode.parentN
if (event.keyCode == 40) //向下的时候
if (tr.rowIndex & tr.parentNode.rows.length - 1)
tr.parentNode.rows[tr.rowIndex + 1].cells[obj.parentNode.cellIndex].children[0].focus();
if (event.keyCode == 37) //向左的时候
if (obj.parentNode.cellIndex & 0) {
var i = 1;
var node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex - i].children[0];
while (!(node.nodeName == &INPUT&||node.nodeName == &TEXTAREA&) && obj.parentNode.cellIndex - 1 &= 0) {
i++;
node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex - i].children[0];
node.focus();
node.select();
if (event.keyCode == 39) //向右的时候
if (obj.parentNode.cellIndex & tr.cells.length - 1) {
var i = 1;
var node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex + i].children[0];
while (!(node.nodeName == &INPUT& || node.nodeName == &TEXTAREA&) && obj.parentNode.cellIndex & tr.cells.length - 1) {
i++;
node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex + i].children[0];
node.focus();
node.select();
if (event.keyCode == 38) //向上的时候
if (tr.rowIndex & 1)
tr.parentNode.rows[tr.rowIndex - 1].cells[obj.parentNode.cellIndex].children[0].focus();
}&/script&
C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!
在移动的时候判断是否是隐藏的..是隐藏的就跳过... &估计是移动到隐藏的单元格去了!
这个脚本是您写出来的,想继续问问这个隐藏的判断该怎么写呢?呵呵!
& & 下面是我做的一个完整的测试代码,如果隐藏了就移动不了!按多少下都不行,也就是说遇到隐藏的列就卡在那里了!
--------------------------前台---------------------------
&%@ Page Language=&C#& AutoEventWireup=&true& CodeFile=&Default2.aspx.cs& Inherits=&Try_Default2& %&
&!DOCTYPE html PUBLIC &-//W3C//DTD XHTML 1.0 Transitional//EN& &http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&&
&html xmlns=&http://www.w3.org/1999/xhtml&&
&head runat=&server&&
&title&&/title&
&style type=&text/css&&
.style1 {width: 500%;}
.hidden {display:}
.visible{display:}
&script src=&/jquery-1.7.2.min.js& type=&text/javascript&&&/script&
&script type=&text/javascript&&
function enter(obj) {
var tr = obj.parentNode.parentN
if (event.keyCode == 40) //向下的时候
if (tr.rowIndex & tr.parentNode.rows.length - 1)
tr.parentNode.rows[tr.rowIndex + 1].cells[obj.parentNode.cellIndex].children[0].focus();
if (event.keyCode == 37) //向左的时候
if (obj.parentNode.cellIndex & 0) {
var i = 1;
var node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex - i].children[0];
while (!(node.nodeName == &INPUT& || node.nodeName == &TEXTAREA&) && obj.parentNode.cellIndex - 1 &= 0) {
i++;
node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex - i].children[0];
node.focus();
node.select();
if (event.keyCode == 39) //向右的时候
if (obj.parentNode.cellIndex & tr.cells.length - 1) {
var i = 1;
var node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex + i].children[0];
while (!(node.nodeName == &INPUT& || node.nodeName == &TEXTAREA&) && obj.parentNode.cellIndex & tr.cells.length - 1) {
i++;
node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex + i].children[0];
node.focus();
node.select();
if (event.keyCode == 38) //向上的时候
if (tr.rowIndex & 1)
tr.parentNode.rows[tr.rowIndex - 1].cells[obj.parentNode.cellIndex].children[0].focus();
&form id=&form1& runat=&server&&
&table cellpadding=&0& cellspacing=&0& class=&style1&&
&asp:CheckBoxList ID=&CheckBoxList_All& runat=&server&
RepeatDirection=&Horizontal& &
&asp:ListItem&1&/asp:ListItem&
&asp:ListItem&2&/asp:ListItem&
&asp:ListItem&3&/asp:ListItem&
&asp:ListItem&4&/asp:ListItem&
&asp:ListItem&5&/asp:ListItem&
&asp:ListItem&6&/asp:ListItem&
&asp:ListItem&7&/asp:ListItem&
&asp:ListItem&8&/asp:ListItem&
&/asp:CheckBoxList&
&asp:Button ID=&Button3& runat=&server& Text=&隐藏或显示&
onclick=&Button3_Click& /&
&asp:GridView ID=&GridView_Search& runat=&server& AutoGenerateColumns=&False&
DataKeyNames=&PRID& DataSourceID=&SqlDataSource_Search& CellPadding=&0&&
&asp:TemplateField HeaderText=&年份& SortExpression=&ReceivableID&
&ItemTemplate&
&asp:TextBox ID=&TextBox1& runat=&server& Text='&%# Bind(&ReceivableID&) %&' onkeyup=&enter(this)& &&/asp:TextBox&
&/ItemTemplate&
&ControlStyle
Width=&33px&&&/ControlStyle&
&/asp:TemplateField&
&asp:TemplateField HeaderText=&资产编号& SortExpression=&PropertyIDR& &
&ItemTemplate&
&asp:TextBox ID=&TextBox2& runat=&server& Text='&%# Bind(&PropertyIDR&) %&' onkeyup=&enter(this)& &&/asp:TextBox&
&/ItemTemplate&
&/asp:TemplateField&
&asp:BoundField DataField=&PRID& HeaderText=&编号&
&ControlStyle Width=&30px&&&/ControlStyle&
&/asp:BoundField&
&asp:TemplateField HeaderText=&ContractNumberR&
SortExpression=&ContractNumberR&&
&ItemTemplate&
&asp:TextBox ID=&TextBox3& runat=&server& Text='&%# Bind(&ContractNumberR&) %&' onkeyup=&enter(this)& &&/asp:TextBox&
&/ItemTemplate&
&/asp:TemplateField&
&asp:TemplateField HeaderText=&ManageProjectR& SortExpression=&ManageProjectR&&
&ItemTemplate&
&asp:TextBox ID=&TextBox4& runat=&server& Text='&%# Bind(&ManageProjectR&) %&' onkeyup=&enter(this)& &&/asp:TextBox&
&/ItemTemplate&
&/asp:TemplateField&
&asp:TemplateField HeaderText=&PropertyCityR& SortExpression=&PropertyCityR&&
&ItemTemplate&
&asp:TextBox ID=&TextBox5& runat=&server& Text='&%# Bind(&PropertyCityR&) %&' onkeyup=&enter(this)& &&/asp:TextBox&
&/ItemTemplate&
&/asp:TemplateField&
&asp:TemplateField HeaderText=&PropertyRoadR& SortExpression=&PropertyRoadR&&
&ItemTemplate&
&asp:TextBox ID=&TextBox6& runat=&server& Text='&%# Bind(&PropertyRoadR&) %&' onkeyup=&enter(this)& &&/asp:TextBox&
&/ItemTemplate&
&/asp:TemplateField&
&asp:TemplateField HeaderText=&PropertyAddressR&
SortExpression=&PropertyAddressR&&
&ItemTemplate&
&asp:TextBox ID=&TextBox7& runat=&server&
Text='&%# Bind(&PropertyAddressR&) %&' onkeyup=&enter(this)& &&/asp:TextBox&
&/ItemTemplate&
&/asp:TemplateField&
&/Columns&
&/asp:GridView&
&asp:SqlDataSource ID=&SqlDataSource_Search& runat=&server&
ConnectionString=&&%$ ConnectionStrings:长铁物业公司资产数据库ConnectionString %&&
DeleteCommand=&DELETE FROM [ReceivableTable] WHERE [PRID] = @PRID&
InsertCommand=&INSERT INTO [ReceivableTable] ([ReceivableID], [PropertyIDR], [ContractNumberR], [ManageProjectR], [PropertyCityR], [PropertyRoadR], [PropertyAddressR]) VALUES (@ReceivableID, @PropertyIDR, @ContractNumberR, @ManageProjectR, @PropertyCityR, @PropertyRoadR, @PropertyAddressR)&
SelectCommand=&SELECT [ReceivableID], [PropertyIDR], [PRID], [ContractNumberR], [ManageProjectR], [PropertyCityR], [PropertyRoadR], [PropertyAddressR] FROM [ReceivableTable]&
UpdateCommand=&UPDATE [ReceivableTable] SET [ReceivableID] = @ReceivableID, [PropertyIDR] = @PropertyIDR, [ContractNumberR] = @ContractNumberR, [ManageProjectR] = @ManageProjectR, [PropertyCityR] = @PropertyCityR, [PropertyRoadR] = @PropertyRoadR, [PropertyAddressR] = @PropertyAddressR WHERE [PRID] = @PRID&&
&DeleteParameters&
&asp:Parameter Name=&PRID& Type=&Int32& /&
&/DeleteParameters&
&UpdateParameters&
&asp:Parameter Name=&ReceivableID& Type=&Int32& /&
&asp:Parameter Name=&PropertyIDR& Type=&Int32& /&
&asp:Parameter Name=&ContractNumberR& Type=&String& /&
&asp:Parameter Name=&ManageProjectR& Type=&String& /&
&asp:Parameter Name=&PropertyCityR& Type=&String& /&
&asp:Parameter Name=&PropertyRoadR& Type=&String& /&
&asp:Parameter Name=&PropertyAddressR& Type=&String& /&
&asp:Parameter Name=&PRID& Type=&Int32& /&
&/UpdateParameters&
&InsertParameters&
&asp:Parameter Name=&ReceivableID& Type=&Int32& /&
&asp:Parameter Name=&PropertyIDR& Type=&Int32& /&
&asp:Parameter Name=&ContractNumberR& Type=&String& /&
&asp:Parameter Name=&ManageProjectR& Type=&String& /&
&asp:Parameter Name=&PropertyCityR& Type=&String& /&
&asp:Parameter Name=&PropertyRoadR& Type=&String& /&
&asp:Parameter Name=&PropertyAddressR& Type=&String& /&
&/InsertParameters&
&/asp:SqlDataSource&
--------------------------------后台--------------------------
using System.Collections.G
using System.L
using System.W
using System.Web.UI;
using System.Web.UI.WebC
public partial class Try_Default2 : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
protected void Button3_Click(object sender, EventArgs e)
HiddenOrInline();
protected void HiddenOrInline()
for (int i = 0; i & CheckBoxList_All.Items.C i++)
if (CheckBoxList_All.Items[i].Selected == true)
GridView_Search.Columns[i].HeaderStyle.CssClass = &inline&;
GridView_Search.Columns[i].FooterStyle.CssClass = &inline&;
GridView_Search.Columns[i].ItemStyle.CssClass = &inline&;
GridView_Search.Columns[i].HeaderStyle.CssClass = &hidden&;
GridView_Search.Columns[i].FooterStyle.CssClass = &hidden&;
GridView_Search.Columns[i].ItemStyle.CssClass = &hidden&;
C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!
&asp:TemplateField HeaderText=&ContractNumberR& SortExpression=&ContractNumberR&&
&ItemTemplate&
&asp:Label
ID=&sss111& runat=&server& Text='&%# Bind(&yqwcrq&) %&' /&
&/ItemTemplate&
&/asp:TemplateField&
我看了下 建议不要用上面的代码,这个脚本不适用,可以改成我下面给你的代码,你试试看,有什么问题 再回复!
&asp:BoundField DataField=&jyyj& HeaderText=&编号&&
&ControlStyle Width=&30px&&&/ControlStyle&
&/asp:BoundField&
& & 谢谢您的提示!
& & 可是 &我必须用模板才能更新那些数据,所以如果还是要用TemplateField。我遇见的问题主要是当某些列的Style.Cssclass=Hidden时,脚本就提示找不到那一列。错误提示如前面的图。
& & 因此,该如何在脚本中加入 &对隐藏列 的判断,使之顺利移动呢?
C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!
帮你搞定了。。我贴出代码
&%@ Page Title=&主页& Language=&C#& AutoEventWireup=&true& CodeBehind=&Default.aspx.cs&
Inherits=&WebApplication3._Default& %&
&html xmlns=&http://www.w3.org/1999/xhtml&&
&head id=&Head1& runat=&server&&
&title&&/title&
&style type=&text/css&&
width: 500%;
&script src=&/jquery-1.7.2.min.js& type=&text/javascript&&&/script&
&script type=&text/javascript&&
function enter(obj) {
var tr = obj.parentNode.parentN
if (event.keyCode == 40) //向下的时候
if (tr.rowIndex & tr.parentNode.rows.length - 1)
tr.parentNode.rows[tr.rowIndex + 1].cells[obj.parentNode.cellIndex].children[0].focus();
if (event.keyCode == 37) //向左的时候
if (obj.parentNode.cellIndex & 0) {
var i = 1;
while (tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex - i].children.length == 0) {
i++;
var node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex - i].children[0];
while (node==undefined||(!(node.nodeName == &INPUT& || node.nodeName == &TEXTAREA&) && obj.parentNode.cellIndex - 1 &= 0)) {
i++;
node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex - i].children[0];
if (node != undefined) {
node.focus();
node.select();
if (event.keyCode == 39) //向右的时候
if (obj.parentNode.cellIndex & tr.cells.length - 1) {
var i = 1;
while (tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex - i].children.length == 0) {
i++;
var node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex + i].children[0];
while (node == undefined ||( !(node.nodeName == &INPUT& || node.nodeName == &TEXTAREA&) && obj.parentNode.cellIndex & tr.cells.length - 1)) {
i++;
node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex + i].children[0];
if (node != undefined) {
node.focus();
node.select();
if (event.keyCode == 38) //向上的时候
if (tr.rowIndex & 1)
tr.parentNode.rows[tr.rowIndex - 1].cells[obj.parentNode.cellIndex].children[0].focus();
&form id=&form1& runat=&server&&
&table cellpadding=&0& cellspacing=&0& class=&style1&&
&asp:CheckBoxList ID=&CheckBoxList_All& runat=&server& RepeatDirection=&Horizontal&&
&asp:ListItem&1&/asp:ListItem&
&asp:ListItem&2&/asp:ListItem&
&asp:ListItem&3&/asp:ListItem&
&asp:ListItem&4&/asp:ListItem&
&asp:ListItem&5&/asp:ListItem&
&asp:ListItem&6&/asp:ListItem&
&asp:ListItem&7&/asp:ListItem&
&asp:ListItem&8&/asp:ListItem&
&/asp:CheckBoxList&
&asp:Button ID=&Button3& runat=&server& Text=&隐藏或显示& OnClick=&Button3_Click& /&
&asp:GridView ID=&GridView_Search& runat=&server& AutoGenerateColumns=&False& CellPadding=&0&&
&asp:TemplateField HeaderText=&年份& SortExpression=&ReceivableID&&
&ItemTemplate&
&asp:TextBox ID=&TextBox1& runat=&server& Text='&%# Bind(&sjbm&) %&' onkeyup=&enter(this)&&&/asp:TextBox&
&/ItemTemplate&
&ControlStyle Width=&33px&&&/ControlStyle&
&/asp:TemplateField&
&asp:TemplateField HeaderText=&资产编号& SortExpression=&PropertyIDR&&
&ItemTemplate&
&asp:TextBox ID=&TextBox2& runat=&server& Text='&%# Bind(&yqwcrq&) %&' onkeyup=&enter(this)&&&/asp:TextBox&
&/ItemTemplate&
&/asp:TemplateField&
&asp:BoundField DataField=&jyyj& HeaderText=&编号&&
&ControlStyle Width=&30px&&&/ControlStyle&
&/asp:BoundField&
&asp:TemplateField HeaderText=&ContractNumberR& SortExpression=&ContractNumberR&&
&ItemTemplate&
&asp:Label ID=&sss111& runat=&server& Text='&%# Bind(&yqwcrq&) %&' /&
&/ItemTemplate&
&/asp:TemplateField&
&asp:TemplateField HeaderText=&ContractNumberR& SortExpression=&ContractNumberR&&
&ItemTemplate&
&asp:TextBox ID=&TextBox3& runat=&server& Text='&%# Bind(&jyyj&) %&' onkeyup=&enter(this)&&&/asp:TextBox&
&/ItemTemplate&
&/asp:TemplateField&
&asp:TemplateField HeaderText=&ManageProjectR& SortExpression=&ManageProjectR&&
&ItemTemplate&
&asp:TextBox ID=&TextBox4& runat=&server& Text='&%# Bind(&jyyj&) %&' onkeyup=&enter(this)&&&/asp:TextBox&
&/ItemTemplate&
&/asp:TemplateField&
&asp:TemplateField HeaderText=&PropertyCityR& SortExpression=&PropertyCityR&&
&ItemTemplate&
&asp:TextBox ID=&TextBox5& runat=&server& Text='&%# Bind(&jyyj&) %&' onkeyup=&enter(this)&&&/asp:TextBox&
&/ItemTemplate&
&/asp:TemplateField&
&asp:TemplateField HeaderText=&PropertyRoadR& SortExpression=&PropertyRoadR&&
&ItemTemplate&
&asp:TextBox ID=&TextBox6& runat=&server& Text='&%# Bind(&jyyj&) %&' onkeyup=&enter(this)&&&/asp:TextBox&
&/ItemTemplate&
&/asp:TemplateField&
&asp:TemplateField HeaderText=&PropertyAddressR& SortExpression=&PropertyAddressR&&
&ItemTemplate&
&asp:TextBox ID=&TextBox7& runat=&server& Text='&%# Bind(&jyyj&) %&' onkeyup=&enter(this)&&&/asp:TextBox&
&/ItemTemplate&
&/asp:TemplateField&
&/Columns&
&/asp:GridView&
using System.Collections.G
using System.L
using System.W
using System.Web.UI;
using System.Web.UI.WebC
using System.D
namespace WebApplication3
public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
DataTable dt1 = new DataTable(&All&);
dt1.Columns.Add(&sjbm&);//送检部门
dt1.Columns.Add(&yqwcrq&);//要求完成日期
dt1.Columns.Add(&jyyj&);//检验依据
for (int i = 0; i & 10; i++)
DataRow dr = dt1.NewRow();
dr[&sjbm&] =
dr[&yqwcrq&] =
dr[&jyyj&] =
dt1.Rows.Add(dr);
GridView_Search.DataSource = dt1;
GridView_Search.DataBind();
protected void Button3_Click(object sender, EventArgs e)
HiddenOrInline();
protected void HiddenOrInline()
for (int i = 0; i & CheckBoxList_All.Items.C i++)
if (CheckBoxList_All.Items[i].Selected == true)
GridView_Search.Columns[i].HeaderStyle.CssClass = &inline&;
GridView_Search.Columns[i].FooterStyle.CssClass = &inline&;
GridView_Search.Columns[i].ItemStyle.CssClass = &inline&;
GridView_Search.Columns[i].HeaderStyle.CssClass = &hidden&;
GridView_Search.Columns[i].FooterStyle.CssClass = &hidden&;
GridView_Search.Columns[i].ItemStyle.CssClass = &hidden&;
试试看,我顺利通过了!
已標示為解答
已取消標示為解答
谢谢您的解答!在本机上用VS2008调试运行成功了,可是我用网页打开的话这个脚本就不起作用,用其他电脑上联网运行这个网页,这个脚本同样不起作用。
应该怎么样设置才能在非VS2008调试的情况下也能正常运行呢???
C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!
你的VS2008调试运行成功了 是什么意思? 是编译通过?& 然后运行的时候不行? 有报什么错误吗? 能截图看看吗?
就是用VS2008调试,点击那个绿色的小三角形,打开的界面可以用方向键移动到其他单元格;但我直接用浏览器打开,其他都正常,没有错误提示!唯独这个脚本就没有效果,方向键没作用!左下角提示好像是“ JavaScript 脚本错误” ,明天我截个图上来给您看。C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!
点三角形那个调试按钮可以的话 应该直接打开也是可以的。。。方便的话 给我一个错误的截图& 谢谢!
& & &谢谢您的解答!“JavaScript脚本错误”的问题给我蒙好了!目前又出现了一个新情况!
& & 我用VS2008调试了这个方向键自由移动的脚本配合CSS中的.hidden {display:}和 .visible{display:}两个样式,在隐藏了某些列的情况下运行都没有问题。代码都在上面有。
& & 我直接打开网站,浏览该网页,又出现了一个问题。只要某一列的样式Cssclass=&hidden&,这个脚本又不能正常运行了。例如我隐藏了列:“02月收入”,那么在“02月收入”的左侧的所有单元格中,方向键都能够自由移动,一旦到了“02月收入”列的右边,也就是图中的“03月收入”开始,方向键就乱走了。假如我把鼠标焦点定在1的位置,点“向下方向键”,焦点会出现在2的位置;再点“向下方向键”,焦点会出现图中所提示的错误。
& & 在VS2008中调试就没有这种问题,请问对于这种情况还要如何改进呢?
C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!
&script type=&text/javascript&&
function enter(obj) {
var tr = obj.parentNode.parentN
if (event.keyCode == 40) //向下的时候
if (tr.rowIndex & tr.parentNode.rows.length - 1)
tr.parentNode.rows[tr.rowIndex + 1].cells[obj.parentNode.cellIndex].children[0].focus();
if (event.keyCode == 37) //向左的时候
if (obj.parentNode.cellIndex & 0) {
var i = 1;
while (tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex - i].children.length == 0) {
i++;
var node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex - i].children[0];
while (node == undefined || node.attributes[&class&].value == &hidden& || (!(node.nodeName == &INPUT& || node.nodeName == &TEXTAREA&) && obj.parentNode.cellIndex - 1 &= 0)) {
i++;
node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex - i].children[0];
if (node != undefined) {
node.focus();
node.select();
if (event.keyCode == 39) //向右的时候
if (obj.parentNode.cellIndex & tr.cells.length - 1) {
var i = 1;
while (tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex + i].children.length == 0) {
i++;
var node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex + i].children[0];
while (node == undefined || node.attributes[&class&].value == &hidden& || (!(node.nodeName == &INPUT& || node.nodeName == &TEXTAREA&) && obj.parentNode.cellIndex & tr.cells.length - 1)) {
i++;
node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex + i].children[0];
if (node != undefined) {
node.focus();
node.select();
if (event.keyCode == 38) //向上的时候
if (tr.rowIndex & 1)
tr.parentNode.rows[tr.rowIndex - 1].cells[obj.parentNode.cellIndex].children[0].focus();
已经修正了脚本,多判断了&node.attributes[&class&].value == &hidden& 这句话& 你可以改成自己需要的!
谢谢您的解答!
已经修正了脚本,多判断了&node.attributes[&class&].value == &hidden& 这句话& 你可以改成自己需要的!
我应该不用修改什么吧?我直接把这段代码粘贴到我的程序中,发现问题依旧。
1.在VS2008调试中,在某些列隐藏的情况下,只能上下移动,不能左右移动了......
2.在网页浏览中,在某些列隐藏的情况下,还是出现向我楼上说的那种情况,如:“02月收入”隐藏后,它的左边正常,右边上下左右都会错位......所以,上下左右的脚本应该都要修改......
& & 为什么用VS2008调试和网页浏览会出现如此区别?假如只能鱼肉熊掌,我只能选择在网页浏览中正常运行了......头疼!!!C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!
你可以在IE中按F12选择调试& 看看脚本到底是哪里出错了。我一般也是这么做的。。
发现哪里出错的话 可以截图上来& 。。我上面的代码在我本机测试通过的...判断是隐藏列的话 就再往下!
& &试了好多次,在VS2008调试中,您新给的代码不管是否有隐藏列,左右键都移动不了,我实在是找不到解决的办法,只好把完整的代码发上来给您看了!
& & 只有去掉“node.attributes[&class&].value == &hidden&”这一句才能左右移动,所以问题应该就是出在这一句上。您曾经提示说要我根据自己的需要修改“node.attributes[&class&].value == &hidden&”这一句,我看不出要修改什么,因此没做修改!
--------------------------代码1(前台)-----------------------
&%@ Page Language=&C#& AutoEventWireup=&true& CodeFile=&Default2.aspx.cs& Inherits=&Try_Default2& %&
&!DOCTYPE html PUBLIC &-//W3C//DTD XHTML 1.0 Transitional//EN& &http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&&
&html xmlns=&http://www.w3.org/1999/xhtml&&
&head runat=&server&&
&title&&/title&
&style type=&text/css&&
.style1 {width: 500%;}
.hidden {display:}
.visible{display:}
&script src=&/jquery-1.7.2.min.js& type=&text/javascript&&&/script&
&script type=&text/javascript&&
function enter(obj) {
var tr = obj.parentNode.parentN
if (event.keyCode == 40) //向下的时候
if (tr.rowIndex & tr.parentNode.rows.length - 1)
tr.parentNode.rows[tr.rowIndex + 1].cells[obj.parentNode.cellIndex].children[0].focus();
if (event.keyCode == 37) //向左的时候
if (obj.parentNode.cellIndex & 0) {
var i = 1;
while (tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex - i].children.length == 0) {
i++;
var node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex - i].children[0];
while (node == undefined || node.attributes[&class&].value == &hidden& || (!(node.nodeName == &INPUT& || node.nodeName == &TEXTAREA&) && obj.parentNode.cellIndex - 1 &= 0)) {
i++;
node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex - i].children[0];
if (node != undefined) {
node.focus();
node.select();
if (event.keyCode == 39) //向右的时候
if (obj.parentNode.cellIndex & tr.cells.length - 1) {
var i = 1;
while (tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex + i].children.length == 0) {
i++;
var node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex + i].children[0];
while (node == undefined || node.attributes[&class&].value == &hidden& || (!(node.nodeName == &INPUT& || node.nodeName == &TEXTAREA&) && obj.parentNode.cellIndex & tr.cells.length - 1)) {
i++;
node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex + i].children[0];
if (node != undefined) {
node.focus();
node.select();
if (event.keyCode == 38) //向上的时候
if (tr.rowIndex & 1)
tr.parentNode.rows[tr.rowIndex - 1].cells[obj.parentNode.cellIndex].children[0].focus();
&form id=&form1& runat=&server&&
&table cellpadding=&0& cellspacing=&0& class=&style1&&
&asp:CheckBoxList ID=&CheckBoxList_All& runat=&server&
RepeatDirection=&Horizontal& &
&asp:ListItem&1&/asp:ListItem&
&asp:ListItem&2&/asp:ListItem&
&asp:ListItem&3&/asp:ListItem&
&asp:ListItem&4&/asp:ListItem&
&asp:ListItem&5&/asp:ListItem&
&asp:ListItem&6&/asp:ListItem&
&asp:ListItem&7&/asp:ListItem&
&asp:ListItem&8&/asp:ListItem&
&/asp:CheckBoxList&
&asp:Button ID=&Button3& runat=&server& Text=&隐藏或显示&
onclick=&Button3_Click& /&
&asp:GridView ID=&GridView_Search& runat=&server& AutoGenerateColumns=&False&
DataKeyNames=&PRID& DataSourceID=&SqlDataSource_Search& CellPadding=&0&&
&asp:TemplateField HeaderText=&年份& SortExpression=&ReceivableID&
&ItemTemplate&
&asp:TextBox ID=&TextBox1& runat=&server& Text='&%# Bind(&ReceivableID&) %&' onkeyup=&enter(this)& &&/asp:TextBox&
&/ItemTemplate&
&ControlStyle
Width=&33px&&&/ControlStyle&
&/asp:TemplateField&
&asp:TemplateField HeaderText=&资产编号& SortExpression=&PropertyIDR& &
&ItemTemplate&
&asp:TextBox ID=&TextBox2& runat=&server& Text='&%# Bind(&PropertyIDR&) %&' onkeyup=&enter(this)& &&/asp:TextBox&
&/ItemTemplate&
&/asp:TemplateField&
&asp:TemplateField HeaderText=&编号&&
&ItemTemplate&
&asp:Label ID=&Label1& runat=&server& Text='&%# Bind(&PRID&) %&' onkeyup=&enter(this)& &&/asp:Label&
&/ItemTemplate&
&ControlStyle Width=&30px& /&
&/asp:TemplateField&
&asp:TemplateField HeaderText=&ContractNumberR&
SortExpression=&ContractNumberR&&
&ItemTemplate&
&asp:TextBox ID=&TextBox3& runat=&server& Text='&%# Bind(&ContractNumberR&) %&' onkeyup=&enter(this)& &&/asp:TextBox&
&/ItemTemplate&
&/asp:TemplateField&
&asp:TemplateField HeaderText=&ManageProjectR& SortExpression=&ManageProjectR&&
&ItemTemplate&
&asp:TextBox ID=&TextBox4& runat=&server& Text='&%# Bind(&ManageProjectR&) %&' onkeyup=&enter(this)& &&/asp:TextBox&
&/ItemTemplate&
&/asp:TemplateField&
&asp:TemplateField HeaderText=&PropertyCityR& SortExpression=&PropertyCityR&&
&ItemTemplate&
&asp:TextBox ID=&TextBox5& runat=&server& Text='&%# Bind(&PropertyCityR&) %&' onkeyup=&enter(this)& &&/asp:TextBox&
&/ItemTemplate&
&/asp:TemplateField&
&asp:TemplateField HeaderText=&PropertyRoadR& SortExpression=&PropertyRoadR&&
&ItemTemplate&
&asp:TextBox ID=&TextBox6& runat=&server& Text='&%# Bind(&PropertyRoadR&) %&' onkeyup=&enter(this)& &&/asp:TextBox&
&/ItemTemplate&
&/asp:TemplateField&
&asp:TemplateField HeaderText=&PropertyAddressR&
SortExpression=&PropertyAddressR&&
&ItemTemplate&
&asp:TextBox ID=&TextBox7& runat=&server&
Text='&%# Bind(&PropertyAddressR&) %&' onkeyup=&enter(this)& &&/asp:TextBox&
&/ItemTemplate&
&/asp:TemplateField&
&/Columns&
&/asp:GridView&
&asp:SqlDataSource ID=&SqlDataSource_Search& runat=&server&
ConnectionString=&&%$ ConnectionStrings:长铁物业公司资产数据库ConnectionString %&&
DeleteCommand=&DELETE FROM [ReceivableTable] WHERE [PRID] = @PRID&
InsertCommand=&INSERT INTO [ReceivableTable] ([ReceivableID], [PropertyIDR], [ContractNumberR], [ManageProjectR], [PropertyCityR], [PropertyRoadR], [PropertyAddressR]) VALUES (@ReceivableID, @PropertyIDR, @ContractNumberR, @ManageProjectR, @PropertyCityR, @PropertyRoadR, @PropertyAddressR)&
SelectCommand=&SELECT [ReceivableID], [PropertyIDR], [PRID], [ContractNumberR], [ManageProjectR], [PropertyCityR], [PropertyRoadR], [PropertyAddressR] FROM [ReceivableTable]&
UpdateCommand=&UPDATE [ReceivableTable] SET [ReceivableID] = @ReceivableID, [PropertyIDR] = @PropertyIDR, [ContractNumberR] = @ContractNumberR, [ManageProjectR] = @ManageProjectR, [PropertyCityR] = @PropertyCityR, [PropertyRoadR] = @PropertyRoadR, [PropertyAddressR] = @PropertyAddressR WHERE [PRID] = @PRID&&
&DeleteParameters&
&asp:Parameter Name=&PRID& Type=&Int32& /&
&/DeleteParameters&
&UpdateParameters&
&asp:Parameter Name=&ReceivableID& Type=&Int32& /&
&asp:Parameter Name=&PropertyIDR& Type=&Int32& /&
&asp:Parameter Name=&ContractNumberR& Type=&String& /&
&asp:Parameter Name=&ManageProjectR& Type=&String& /&
&asp:Parameter Name=&PropertyCityR& Type=&String& /&
&asp:Parameter Name=&PropertyRoadR& Type=&String& /&
&asp:Parameter Name=&PropertyAddressR& Type=&String& /&
&asp:Parameter Name=&PRID& Type=&Int32& /&
&/UpdateParameters&
&InsertParameters&
&asp:Parameter Name=&ReceivableID& Type=&Int32& /&
&asp:Parameter Name=&PropertyIDR& Type=&Int32& /&
&asp:Parameter Name=&ContractNumberR& Type=&String& /&
&asp:Parameter Name=&ManageProjectR& Type=&String& /&
&asp:Parameter Name=&PropertyCityR& Type=&String& /&
&asp:Parameter Name=&PropertyRoadR& Type=&String& /&
&asp:Parameter Name=&PropertyAddressR& Type=&String& /&
&/InsertParameters&
&/asp:SqlDataSource&
--------------------------------代码2(后台)--------------------------------------
using System.Collections.G
using System.L
using System.W
using System.Web.UI;
using System.Web.UI.WebC
using Word = Microsoft.Office.Interop.W
using System.T
using office = Microsoft.Office.C
using System.R
using System.IO;
using System.Text.RegularE
using System.T
using System.Data.SqlC
using System.C
public partial class Try_Default2 : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
protected void Button3_Click(object sender, EventArgs e)
HiddenOrInline();
protected void HiddenOrInline()
for (int i = 0; i & CheckBoxList_All.Items.C i++)
if (CheckBoxList_All.Items[i].Selected == true)
GridView_Search.Columns[i].HeaderStyle.CssClass = &inline&;
GridView_Search.Columns[i].FooterStyle.CssClass = &inline&;
GridView_Search.Columns[i].ItemStyle.CssClass = &inline&;
GridView_Search.Columns[i].HeaderStyle.CssClass = &hidden&;
GridView_Search.Columns[i].FooterStyle.CssClass = &hidden&;
GridView_Search.Columns[i].ItemStyle.CssClass = &hidden&;
C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!
我是根据你的代码写的。。。本机测试通过的
我放出下载地址 你下载看看:
& & 这个问题问了您这么久了我都不好意思了。昨晚我在家里的电脑上把您的代码解压下来,特意新建了一个网站尝试,然而问题依旧。今天又在单位的电脑上再次测试了这个解压后的代码,还是一样!只能上下移动,不能左右移动。
& & 于是我仔细研究了您的代码,发现和我的略有不同,比如:
1.您的代码总共有9列,而CheckBoxList只设置了8个项。
2.&asp:TextBox ID=&TextBox4& CssClass=&hidden& runat=&server& Text='&%# Bind(&jyyj&) %&'这一句多了个 CssClass=&hidden& 。
3.&asp:Label ID=&sss111& runat=&server& Text='&%# Bind(&yqwcrq&) %&' /& &没有onkeyup=&enter(this)&。
& & 是不是这些不同之处造成的呢?C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!
你好 可能浏览器的兼容性 不好& 我目前用的是ie10&&
我可以尝试着用jquery 写一个给你看看... 不过你最好能够给出我错误的地方 是这句话node.attributes[&class&].value == &hidden&吗?
.&asp:TextBox ID=&TextBox4& CssClass=&hidden& runat=&server& Text='&%# Bind(&jyyj&) %&'这一句多了个 CssClass=&hidden& 。
和后台里面写GridView_Search.Columns[i].HeaderStyle.CssClass
= &hidden&;是一样的。。。
你可以在报错的时候点确定查看下 报错的位置..如果你熟悉调试的话 我相信你可以自己解决这些问题了!
我就是不熟悉调试咯!而且也并没有报错!就是加了node.attributes[&class&].value == &hidden&之后左右移动不了了。。。
以前您写的脚本针对没有使用cssclass=“hidden”前挺好用的,但我加入cssclass=“hidden”的条件后就动不了了!也没报错,就是左右动不了。我用的是360高速浏览器,IE的版本是IE6,开发工具是VS2008!
& & 而且我看见您的程序中中还有很多其他的东西,而我只有一个Default1的前台和后台,我是不是还需要加点别的什么东西呢?
C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!
其他页面都没用的,那只是一个demo
不然 你试试把node.attributes[&class&].value改成node.className& 这2个效果一样的 .试试看 一般是可以的
& & 按照您的提示我把node.attributes[&class&].value==&hidden&&改成node.classname==&hidden&
,结果是:在没有隐藏列的情况下可以很好的运行!但隐藏了某列后,焦点到了该列附近就不能再继续移动了。
& & 例如我隐藏了第5列,那么焦点就不能跨过隐藏着的第5列,在4和6列之间移动,只能在1~4和 &6~8列之间正确移动。之前使用node.attributes[&class&].value==&hidden&,是根本不能左右移动。
& & 而且IE不会弹出任何的错误提示。
& & 我感觉很接近了,呵呵!(另外说一下,我用的是WindowsXP,Vs高速浏览器和IE6,不知道是否有影响)
C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!
应该还是获取class 属性出错了 所以没有移动..你确定你的class 里面是hidden吗? 你可以点击网页查看下源代码 看看& 如果不是的话 就要修改 另外你有用jquery吗?
有的话可以试试下面的写法
node.attr('class')&&
我查看了网页的源代码,以下是1~9列种4、5、6列隐藏的情况下:要如何修改呢?
这样看着好累吧?回头我给您截个图,比较好看!
&table cellspacing=&0& cellpadding=&0& rules=&all& border=&1& id=&GridView_Search& style=&border-collapse:&&
&tr& &th class=&inline& scope=&col&&1&/th&&th class=&inline& scope=&col&&2&/th&&th class=&inline& scope=&col&&3&/th&&th class=&hidden& scope=&col&&4&/th&&th class=&hidden& scope=&col&&5&/th&&th
class=&hidden& scope=&col&&6&/th&&th class=&inline& scope=&col&&7&/th&&th class=&inline& scope=&col&&8&/th&&th class=&inline& scope=&col&&9&/th& &/tr&
&tr& &td class=&inline&& &input name=&GridView_Search$ctl02$TextBox1& type=&text& value=&0& id=&GridView_Search_ctl02_TextBox1& onkeyup=&enter(this)& style=&width:33& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl02$TextBox2&
type=&text& value=&0& id=&GridView_Search_ctl02_TextBox2& onkeyup=&enter(this)& /& &/td&&td class=&inline&&0&/td&&td class=&hidden&& &span id=&GridView_Search_ctl02_sss111&&0&/span& &/td&&td class=&hidden&&
&input name=&GridView_Search$ctl02$TextBox3& type=&text& value=&0& id=&GridView_Search_ctl02_TextBox3& onkeyup=&enter(this)& /& &/td&&td class=&hidden&& &input name=&GridView_Search$ctl02$TextBox4& type=&text& value=&0& id=&GridView_Search_ctl02_TextBox4&
onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl02$TextBox5& type=&text& value=&0& id=&GridView_Search_ctl02_TextBox5& onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl02$TextBox6&
type=&text& value=&0& id=&GridView_Search_ctl02_TextBox6& onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl02$TextBox7& type=&text& value=&0& id=&GridView_Search_ctl02_TextBox7& onkeyup=&enter(this)& /&
&/td& &/tr&
&tr& &td class=&inline&& &input name=&GridView_Search$ctl03$TextBox1& type=&text& value=&1& id=&GridView_Search_ctl03_TextBox1& onkeyup=&enter(this)& style=&width:33& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl03$TextBox2&
type=&text& value=&1& id=&GridView_Search_ctl03_TextBox2& onkeyup=&enter(this)& /& &/td&&td class=&inline&&1&/td&&td class=&hidden&& &span id=&GridView_Search_ctl03_sss111&&1&/span& &/td&&td class=&hidden&&
&input name=&GridView_Search$ctl03$TextBox3& type=&text& value=&1& id=&GridView_Search_ctl03_TextBox3& onkeyup=&enter(this)& /& &/td&&td class=&hidden&& &input name=&GridView_Search$ctl03$TextBox4& type=&text& value=&1& id=&GridView_Search_ctl03_TextBox4&
onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl03$TextBox5& type=&text& value=&1& id=&GridView_Search_ctl03_TextBox5& onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl03$TextBox6&
type=&text& value=&1& id=&GridView_Search_ctl03_TextBox6& onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl03$TextBox7& type=&text& value=&1& id=&GridView_Search_ctl03_TextBox7& onkeyup=&enter(this)& /&
&/td& &/tr&
&tr& &td class=&inline&& &input name=&GridView_Search$ctl04$TextBox1& type=&text& value=&2& id=&GridView_Search_ctl04_TextBox1& onkeyup=&enter(this)& style=&width:33& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl04$TextBox2&
type=&text& value=&2& id=&GridView_Search_ctl04_TextBox2& onkeyup=&enter(this)& /& &/td&&td class=&inline&&2&/td&&td class=&hidden&& &span id=&GridView_Search_ctl04_sss111&&2&/span& &/td&&td class=&hidden&&
&input name=&GridView_Search$ctl04$TextBox3& type=&text& value=&2& id=&GridView_Search_ctl04_TextBox3& onkeyup=&enter(this)& /& &/td&&td class=&hidden&& &input name=&GridView_Search$ctl04$TextBox4& type=&text& value=&2& id=&GridView_Search_ctl04_TextBox4&
onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl04$TextBox5& type=&text& value=&2& id=&GridView_Search_ctl04_TextBox5& onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl04$TextBox6&
type=&text& value=&2& id=&GridView_Search_ctl04_TextBox6& onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl04$TextBox7& type=&text& value=&2& id=&GridView_Search_ctl04_TextBox7& onkeyup=&enter(this)& /&
&/td& &/tr&
&tr& &td class=&inline&& &input name=&GridView_Search$ctl05$TextBox1& type=&text& value=&3& id=&GridView_Search_ctl05_TextBox1& onkeyup=&enter(this)& style=&width:33& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl05$TextBox2&
type=&text& value=&3& id=&GridView_Search_ctl05_TextBox2& onkeyup=&enter(this)& /& &/td&&td class=&inline&&3&/td&&td class=&hidden&& &span id=&GridView_Search_ctl05_sss111&&3&/span& &/td&&td class=&hidden&&
&input name=&GridView_Search$ctl05$TextBox3& type=&text& value=&3& id=&GridView_Search_ctl05_TextBox3& onkeyup=&enter(this)& /& &/td&&td class=&hidden&& &input name=&GridView_Search$ctl05$TextBox4& type=&text& value=&3& id=&GridView_Search_ctl05_TextBox4&
onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl05$TextBox5& type=&text& value=&3& id=&GridView_Search_ctl05_TextBox5& onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl05$TextBox6&
type=&text& value=&3& id=&GridView_Search_ctl05_TextBox6& onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl05$TextBox7& type=&text& value=&3& id=&GridView_Search_ctl05_TextBox7& onkeyup=&enter(this)& /&
&/td& &/tr&
&tr& &td class=&inline&& &input name=&GridView_Search$ctl06$TextBox1& type=&text& value=&4& id=&GridView_Search_ctl06_TextBox1& onkeyup=&enter(this)& style=&width:33& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl06$TextBox2&
type=&text& value=&4& id=&GridView_Search_ctl06_TextBox2& onkeyup=&enter(this)& /& &/td&&td class=&inline&&4&/td&&td class=&hidden&& &span id=&GridView_Search_ctl06_sss111&&4&/span& &/td&&td class=&hidden&&
&input name=&GridView_Search$ctl06$TextBox3& type=&text& value=&4& id=&GridView_Search_ctl06_TextBox3& onkeyup=&enter(this)& /& &/td&&td class=&hidden&& &input name=&GridView_Search$ctl06$TextBox4& type=&text& value=&4& id=&GridView_Search_ctl06_TextBox4&
onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl06$TextBox5& type=&text& value=&4& id=&GridView_Search_ctl06_TextBox5& onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl06$TextBox6&
type=&text& value=&4& id=&GridView_Search_ctl06_TextBox6& onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl06$TextBox7& type=&text& value=&4& id=&GridView_Search_ctl06_TextBox7& onkeyup=&enter(this)& /&
&/td& &/tr&
&tr& &td class=&inline&& &input name=&GridView_Search$ctl07$TextBox1& type=&text& value=&5& id=&GridView_Search_ctl07_TextBox1& onkeyup=&enter(this)& style=&width:33& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl07$TextBox2&
type=&text& value=&5& id=&GridView_Search_ctl07_TextBox2& onkeyup=&enter(this)& /& &/td&&td class=&inline&&5&/td&&td class=&hidden&& &span id=&GridView_Search_ctl07_sss111&&5&/span& &/td&&td class=&hidden&&
&input name=&GridView_Search$ctl07$TextBox3& type=&text& value=&5& id=&GridView_Search_ctl07_TextBox3& onkeyup=&enter(this)& /& &/td&&td class=&hidden&& &input name=&GridView_Search$ctl07$TextBox4& type=&text& value=&5& id=&GridView_Search_ctl07_TextBox4&
onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl07$TextBox5& type=&text& value=&5& id=&GridView_Search_ctl07_TextBox5& onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl07$TextBox6&
type=&text& value=&5& id=&GridView_Search_ctl07_TextBox6& onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl07$TextBox7& type=&text& value=&5& id=&GridView_Search_ctl07_TextBox7& onkeyup=&enter(this)& /&
&/td& &/tr&
&tr& &td class=&inline&& &input name=&GridView_Search$ctl08$TextBox1& type=&text& value=&6& id=&GridView_Search_ctl08_TextBox1& onkeyup=&enter(this)& style=&width:33& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl08$TextBox2&
type=&text& value=&6& id=&GridView_Search_ctl08_TextBox2& onkeyup=&enter(this)& /& &/td&&td class=&inline&&6&/td&&td class=&hidden&& &span id=&GridView_Search_ctl08_sss111&&6&/span& &/td&&td class=&hidden&&
&input name=&GridView_Search$ctl08$TextBox3& type=&text& value=&6& id=&GridView_Search_ctl08_TextBox3& onkeyup=&enter(this)& /& &/td&&td class=&hidden&& &input name=&GridView_Search$ctl08$TextBox4& type=&text& value=&6& id=&GridView_Search_ctl08_TextBox4&
onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl08$TextBox5& type=&text& value=&6& id=&GridView_Search_ctl08_TextBox5& onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl08$TextBox6&
type=&text& value=&6& id=&GridView_Search_ctl08_TextBox6& onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl08$TextBox7& type=&text& value=&6& id=&GridView_Search_ctl08_TextBox7& onkeyup=&enter(this)& /&
&/td& &/tr&
&tr& &td class=&inline&& &input name=&GridView_Search$ctl09$TextBox1& type=&text& value=&7& id=&GridView_Search_ctl09_TextBox1& onkeyup=&enter(this)& style=&width:33& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl09$TextBox2&
type=&text& value=&7& id=&GridView_Search_ctl09_TextBox2& onkeyup=&enter(this)& /& &/td&&td class=&inline&&7&/td&&td class=&hidden&& &span id=&GridView_Search_ctl09_sss111&&7&/span& &/td&&td class=&hidden&&
&input name=&GridView_Search$ctl09$TextBox3& type=&text& value=&7& id=&GridView_Search_ctl09_TextBox3& onkeyup=&enter(this)& /& &/td&&td class=&hidden&& &input name=&GridView_Search$ctl09$TextBox4& type=&text& value=&7& id=&GridView_Search_ctl09_TextBox4&
onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl09$TextBox5& type=&text& value=&7& id=&GridView_Search_ctl09_TextBox5& onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl09$TextBox6&
type=&text& value=&7& id=&GridView_Search_ctl09_TextBox6& onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl09$TextBox7& type=&text& value=&7& id=&GridView_Search_ctl09_TextBox7& onkeyup=&enter(this)& /&
&/td& &/tr&
&tr& &td class=&inline&& &input name=&GridView_Search$ctl10$TextBox1& type=&text& value=&8& id=&GridView_Search_ctl10_TextBox1& onkeyup=&enter(this)& style=&width:33& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl10$TextBox2&
type=&text& value=&8& id=&GridView_Search_ctl10_TextBox2& onkeyup=&enter(this)& /& &/td&&td class=&inline&&8&/td&&td class=&hidden&& &span id=&GridView_Search_ctl10_sss111&&8&/span& &/td&&td class=&hidden&&
&input name=&GridView_Search$ctl10$TextBox3& type=&text& value=&8& id=&GridView_Search_ctl10_TextBox3& onkeyup=&enter(this)& /& &/td&&td class=&hidden&& &input name=&GridView_Search$ctl10$TextBox4& type=&text& value=&8& id=&GridView_Search_ctl10_TextBox4&
onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl10$TextBox5& type=&text& value=&8& id=&GridView_Search_ctl10_TextBox5& onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl10$TextBox6&
type=&text& value=&8& id=&GridView_Search_ctl10_TextBox6& onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl10$TextBox7& type=&text& value=&8& id=&GridView_Search_ctl10_TextBox7& onkeyup=&enter(this)& /&
&/td& &/tr&
&tr& &td class=&inline&& &input name=&GridView_Search$ctl11$TextBox1& type=&text& value=&9& id=&GridView_Search_ctl11_TextBox1& onkeyup=&enter(this)& style=&width:33& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl11$TextBox2&
type=&text& value=&9& id=&GridView_Search_ctl11_TextBox2& onkeyup=&enter(this)& /& &/td&&td class=&inline&&9&/td&&td class=&hidden&& &span id=&GridView_Search_ctl11_sss111&&9&/span& &/td&&td class=&hidden&&
&input name=&GridView_Search$ctl11$TextBox3& type=&text& value=&9& id=&GridView_Search_ctl11_TextBox3& onkeyup=&enter(this)& /& &/td&&td class=&hidden&& &input name=&GridView_Search$ctl11$TextBox4& type=&text& value=&9& id=&GridView_Search_ctl11_TextBox4&
onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl11$TextBox5& type=&text& value=&9& id=&GridView_Search_ctl11_TextBox5& onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl11$TextBox6&
type=&text& value=&9& id=&GridView_Search_ctl11_TextBox6& onkeyup=&enter(this)& /& &/td&&td class=&inline&& &input name=&GridView_Search$ctl11$TextBox7& type=&text& value=&9& id=&GridView_Search_ctl11_TextBox7& onkeyup=&enter(this)& /&
&/td& &/tr&
&/table&&/div& &/td& &td& & &/td& &/tr& &/table&
C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!
添加了3幅截图,按从上到下的顺序!不知道是否有帮助!
-------------------------------图1-----------------------------
---------------------------------------图2-------------------------------C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!
----------------------------图3-------------------------
C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!
我发现问题了 应该写成下面的语句 这样就对了!
node.parentNode.className == &hidden&
完整的代码如下
&script type=&text/javascript&&
function enter(obj) {
var tr = obj.parentNode.parentN
if (event.keyCode == 40) //向下的时候
if (tr.rowIndex & tr.parentNode.rows.length - 1)
tr.parentNode.rows[tr.rowIndex + 1].cells[obj.parentNode.cellIndex].children[0].focus();
if (event.keyCode == 37) //向左的时候
if (obj.parentNode.cellIndex & 0) {
var i = 1;
while (tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex - i].children.length == 0) {
i++;
var node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex - i].children[0];
while (node == undefined || node.parentNode.className == &hidden& || (!(node.nodeName == &INPUT& || node.nodeName == &TEXTAREA&) && obj.parentNode.cellIndex - 1 &= 0)) {
i++;
node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex - i].children[0];
if (node != undefined) {
node.focus();
node.select();
if (event.keyCode == 39) //向右的时候
if (obj.parentNode.cellIndex & tr.cells.length - 1) {
var i = 1;
while (tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex + i].children.length == 0) {
i++;
var node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex + i].children[0];
while (node == undefined || node.parentNode.className == &hidden& || (!(node.nodeName == &INPUT& || node.nodeName == &TEXTAREA&) && obj.parentNode.cellIndex & tr.cells.length - 1)) {
i++;
node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex + i].children[0];
if (node != undefined) {
node.focus();
node.select();
if (event.keyCode == 38) //向上的时候
if (tr.rowIndex & 1)
tr.parentNode.rows[tr.rowIndex - 1].cells[obj.parentNode.cellIndex].children[0].focus();
我在chrome 里面测试通过 好像ie10有bug 你试试看!
感谢您的回复!在VS2008调试中,终于完美运行了!那一刻 &我内牛满面......
& & 我很想知道您是如何发现问题所在的。
然后我用360极速浏览器和IE6打开,再次内牛满面......在360高速浏览器和IE6中如果隐藏了列,方向键都会乱走,有时候还会提示如图所示错误:
& & 为啥VS调试成功,IE运行却错乱呢?都是同样的浏览器啊!C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!
& & 根据您的提示我把IE6升级到了IE8,这个脚本用IE8在隐藏列的情况下也可以准确运行了!哈哈!但它在360高速浏览器下还是乱动,不过这都是浏览器的问题,我也管不了那么多了!
& & 在IE8运行下,当焦点到了最靠边的TextBox上,继续点击方向键,就会出现如图所示错误!
问题1:有没有什么办法避免这个错误呢?
问题2:或者,能否设计成当焦点在最左边的单元格了,再按左就跳到上一行的最后一格;同理,当焦点在最右边的单元格,再按右就跳到下一行的第一格呢?
--------------------------------------图1-----------------------------------------
C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!
IE乱走应该属于IE的bug了 ...因为代码确实没错&&&
我也发现乱走问题& 但是在其他浏览器中 比如chrome 均能正常运行
代码修改好了 应该可以防止报错了。。主要加了一个判断if (obj.parentNode.cellIndex - i & 0) 和&&&&&&& if (obj.parentNode.cellIndex & tr.cells.length - 1) 代码如下!
&script type=&text/javascript&&
function enter(obj) {
var tr = obj.parentNode.parentN
if (event.keyCode == 40) //向下的时候
if (tr.rowIndex & tr.parentNode.rows.length - 1)
tr.parentNode.rows[tr.rowIndex + 1].cells[obj.parentNode.cellIndex].children[0].focus();
if (event.keyCode == 37) //向左的时候
if (obj.parentNode.cellIndex & 0) {
var i = 1;
while (tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex - i].children.length == 0) {
i++;
var node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex - i].children[0];
while (node == undefined ||
node.parentNode.className == &hidden& ||
(!(node.nodeName == &INPUT& || node.nodeName == &TEXTAREA&) && obj.parentNode.cellIndex - 1 &= 0)) {
i++;
if (obj.parentNode.cellIndex - i & 0) {
node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex - i].children[0];
if (node != undefined) {
node.focus();
node.select();
if (event.keyCode == 39) //向右的时候
if (obj.parentNode.cellIndex & tr.cells.length - 1) {
var i = 1;
while (tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex + i].children.length == 0) {
i++;
var node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex + i].children[0];
while (node == undefined || node.parentNode.className == &hidden& || (!(node.nodeName == &INPUT& || node.nodeName == &TEXTAREA&) && obj.parentNode.cellIndex & tr.cells.length - 1)) {
i++;
if (obj.parentNode.cellIndex & tr.cells.length - 1) {
node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex + i].children[0];
if (node != undefined) {
node.focus();
node.select();
if (event.keyCode == 38) //向上的时候
if (tr.rowIndex & 1)
tr.parentNode.rows[tr.rowIndex - 1].cells[obj.parentNode.cellIndex].children[0].focus();
其实写这些代码很容易的 只是你没发现窍门& ...很多东西都需要实践才能领悟&& 你可以看看每一行代码 我是怎么样一步一步改写的 自己也试试 一定也可以做到。
刚才没看清楚你的问题 如果你想跳到下一行& 就只要在&&& node =
null; 那个后面 执行向下的代码
&&&&& if (tr.rowIndex
& tr.parentNode.rows.length
&&&&&&&&&&&&&&&&&&& tr.parentNode.rows[tr.rowIndex
+ 1].cells[obj.parentNode.cellIndex].children[0].focus();
&&&&&&&&&&&&&&&
就可以了 你试试看!
这样写么?行不通啊,焦点原地没动。我觉得应该是cells[obj.parentNode.cellIndex]有问题。
if (event.keyCode == 39) //向右的时候
if (obj.parentNode.cellIndex & tr.cells.length - 1) {
var i = 1;
while (tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex + i].children.length == 0) {
i++;
var node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex + i].children[0];
while (node == undefined || node.parentNode.className == &hidden& || (!(node.nodeName == &INPUT& || node.nodeName == &TEXTAREA&) && obj.parentNode.cellIndex & tr.cells.length - 1)) {
i++;
if (obj.parentNode.cellIndex & tr.cells.length - 1) {
node = tr.parentNode.rows[tr.rowIndex].cells[obj.parentNode.cellIndex + i].children[0];
tr.parentNode.rows[tr.rowIndex + 1].cells[obj.parentNode.cellIndex].children[0].focus();
if (node != undefined) {
node.focus();
node.select();
C# 菜鸟中的雏鸟!提的问题也许很幼稚,但我是认真的。希望看在党国的面子上拉兄弟一把!

我要回帖

更多关于 小三泼粪 的文章

 

随机推荐