我在ASP.NET GridView中使用JavaScript。
<script type="text/javascript">
var currentRowId = 0;
function SelectRow()
{
if (event.keyCode == 40)
MarkRow(currentRowId+1);
else if (event.keyCode == 38)
MarkRow(currentRowId-1);
}
function MarkRow(rowId)
{
if (document.getElementById(rowId) == null)
return;
if (document.getElementById(currentRowId) != null )
document.getElementById(currentRowId).style.backgroundColor = #ffffff ;
currentRowId = rowId;
document.getElementById(rowId).style.backgroundColor = #ff0000 ;
}
</script>
<script type="text/javascript">
var TargetBaseControl = null;
window.onload = function()
{
try
{
//get target base control.
TargetBaseControl =
document.getElementById( <%= this.GridView1.ClientID %> );
}
catch(err)
{
TargetBaseControl = null;
}
}
function TestCheckBox()
{
if(TargetBaseControl == null) return false;
//get target child control.
var TargetChildControl = "chkSelect";
//get all the control of the type INPUT in the base control.
var Inputs = TargetBaseControl.getElementsByTagName("input");
for(var n = 0; n < Inputs.length; ++n)
if(Inputs[n].type == checkbox &&
Inputs[n].id.indexOf(TargetChildControl,0) >= 0 &&
Inputs[n].checked)
return true;
alert( Select at least one checkbox! );
return false;
}
</script>
纽扣控制:
Width="80px" CssClass="button" /> 的中文翻译是:“宽度=“80像素”CSS类=“按钮”/ & gt;”。
我在GridView中使用Ajax更新面板...我控制回发级别,但是脚本在更新面板中无法运行。