Microsoft JScript 运行时错误: 'document.Form1.__mytab_State__' 为空或不是对象
<div class="aspNetHidden">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__mytab_State__" id="__mytab_State__" value="0" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKLTY5NTQ2NzEzNQ8WAh4GZmlsdGVyZRYCAgEPZBYOAgYPDxYCHgdUb29sVGlwBQ/ovpPlhaXlhbPplK7lrZcWAh4Jb25rZXlkb3duBRVyZXR1cm4gY2hrRW50ZXJLZXkoKTtkAgcPDxYCHwEFGOWcqOW9k+WJjeWIhuexu+S4reafpeaJvmRkAgkPDxYCHwEFBuWPlua2iGRkAgsPDxYCHgdWaXNpYmxlaGRkAg0PPCsACwIADxYIHghEYXRhS2V5cxYAHgtfIUl0ZW1Db3VudAIBHglQYWdlQ291bnQCAR4VXyFEYXRhU291cmNlSXRlbUNvdW50AgFkARQrAAc8KwAEAQAWAh8DaDwrAAQBABYCHwNnZGRkZGQWAmYPZBYCAgIPD2QWBB4Lb25Nb3VzZU92ZXIFCm1vbih0aGlzKTseCm9uTW91c2VPdXQFC21vdXQodGhpcyk7FgpmD2QWAmYPFQEBN2QCAQ9kFgJmDxUBIzxzcGFuIGNsYXNzPSdzZWxmJz7nrqHnkIblkZg8L3NwYW4+ZAIDD2QWAmYPFQEKMjAxNC0wMy0yNGQCBA9kFgJmDxUBCjIwMTQtMDMtMjdkAgUPZBYCZg8VAQBkAg8PEA9kFgIeB29uY2xpY2sFDHByZUZpbHRlcigpO2RkZAIVDxYCHwNoZBgBBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WAwUFbXl0YWIFBmliRmluZAUIY2JGaWx0ZXI5zK+Z7Xu1LDozl27fpQ21HRbhPGuk7HSDYFfP1iicyw==" />
</div>
------解决方案--------------------正如其错误所示,Form1表单的子级元素列表中不存在Id=_mytab_State_的元素
onSelectedIndexChange="SelectedIndex(this,event)"
//方法一:判断Form1的子元素中是否包含Id为_mytab_State_的元素
function SelectedIndex(obj,e)
{
with(document.Form1)
{
if(_mytab_State_)
{
_mytab_State_.value=e.index;
}
else
{
alert("米有找到元素_mytab_State_");
}
}
}
//方法二:查找元素Id为_mytab_State_的元素再赋值
function SelectedIndex(obj,e)
{
var d=document.getElementById("_mytab_State_");//原生脚本查找
//var d=$("#_mytab_State_").get(0);//使用jQuery库查找
if(d)
{
_mytab_State_.value=e.index;
}
else
{
}
}