您的位置:程序门 -> .net技术 -> asp.net



vs2005中母版的使用中javascript遇到的问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


vs2005中母版的使用中javascript遇到的问题
发表于:2007-01-18 11:14:15 楼主

程序平台:asp.net2.0
编程软件:vs2005
后台语言:c#
前台脚本:javascript

母版页:---------------------------
<html   xmlns= "http://www.w3.org/1999/xhtml "   >
<head   id= "head1 "   runat= "server ">
        <title> 办公自动化系统 </title>
</script>
</head>
<body>
        <form   id= "form1 "   runat= "server ">
        <div>
<asp:contentplaceholder   id= "contentplaceholder1 "   runat= "server "> </asp:contentplaceholder>
        </div>
        </form>
</body>
</html>

子页面:---------------------------
<%@   page   language= "c# "   masterpagefile= "~/masterpage.master "   autoeventwireup= "true "   codefile= "prj_work.aspx.cs "   inherits= "prj_prj_work "   title= "untitled   page "   %>
<asp:content   id= "content1 "   contentplaceholderid= "contentplaceholder1 "   runat= "server ">
<script   language= "javascript "   type   = "text/javascript "   >
function   hidegv()
{
document.all.gv2.style.display= "none ";
}
function   hide1()
{
document.all.gv1.style.display=(document.all.gv1.style.display== "none ")? "block ": "none ";
}
function   hide2()
{
document.all.gv2.style.display=(document.all.gv2.style.display== "none ")? "block ": "none ";
}
</script>
        <table   border= "0 "   cellpadding= "0 "   cellspacing= "5 "   style= "width:   100% "   onload= "showgv() ">
                <tr>
                        <td   colspan= "2 ">
                                &nbsp;   项目管理 </td>
                </tr>
                <tr>
                        <td>
                                <table   cellpadding= "5 "   width= "95% ">
                                        <tr>
                                                <td   onclick= "hide1() ">
                                                        &nbsp;项目前期 </td>
                                        </tr>
                                        <tr>
                                                <td   id= "gv1 "   align= "center ">
                                                        11111111111111 </td>
                                        </tr>
                                        <tr>
                                                <td   onclick= "hide2() ">
                                                        &nbsp;项目执行 </td>
                                        </tr>
                                        <tr>
                                                <td   id= "gv2 "   align= "center ">
                                                2222222222222222 </td>
                                        </tr>
                                </table>
                        </td>
                </tr>
        </table>
</asp:content>

问题:----------------------------
javascript函数hidegv()没有执行!id为“gv2”的td没能隐藏。

如果把函数hidegv()放在母版页的 <body   onload= "hidegv() "> 里,子页面id为“gv2”的td隐藏了,但是在其它引用母版页的子页面就会报错:找不到函数hidegv()或者找不到对象gv2。
发表于:2007-01-18 11:17:491楼 得分:0
var   gv2=   document.getelementbyid( "gv2 ");
gv2.style.display= "none ";
这样试试看
发表于:2007-01-19 09:07:202楼 得分:0
还是不行阿!


快速检索

最新资讯
热门点击