采用母板页的页面使用JavaScript问题

style="MARGIN-TOP: 0px; FLOAT: left" border="0" marginwidth="0" framespacing="0" marginheight="0" src="http://wz.csdn.net/vote.aspx?t=%u91C7%u7528%u6BCD%u677F%u9875%u7684%u9875%u9762%u4F7F%u7528JavaScript%u95EE%u9898%20-%20%u5C0F%u7C73%u7684%u4E13%u680F%20-%20CSDNBlog&u=http%3A//blog.csdn.net/a311300/archive/2006/12/12/1439840.aspx" frameborder="0" noresize="noresize" width="54" scrolling="no" height="75">  采用母板页的页面使用JavaScript问题   <script src="http://blog.csdn.net/count.aspx?ID=1439840&Type=Rank" type="text/javascript"></script>    CSDN Blog推出文章指数概念,文章指数是对Blog文章综合评分后推算出的,综合评分项分别是该文章的点击量,回复次数,被网摘收录数量,文章长度和文章类型;满分100,每月更新一次。

采用母板页的页面,在使用JavaScript时,会发现.net中的控件id,无法获取.

在调试状态下,生成静态页下查看,原来编译器将masterpage当成一个控件,而其中的控件也都会相应的改变id.

会变id为ctl00$模板名称$原名称.例:ctl00$ContentPlaceHolder1$txtSouce

下面写一个例子:

< script language = " javascript "  type = " text/javascript " >
    function CheckInfo()
    
{
      
//如果点击"重置"按钮
      if(event.srcElement.id=='btnClear')
      
{
        document.getElementById(
"ctl00$ContentPlaceHolder1$txtTitle").innerText = "";
        document.getElementById(
"ctl00$ContentPlaceHolder1$txtScore").innerText = "";
        document.getElementById(
"ctl00$ContentPlaceHolder1$txtStartDate").innerText = "";
        document.getElementById(
"ctl00$ContentPlaceHolder1$txtEndDate").innerText = "";
        document.getElementById(
"ctl00$ContentPlaceHolder1$txtContent").innerText = "";
        document.getElementById(
"ctl00$ContentPlaceHolder1$txtSouce").innerText = "";
      }

    }

</ script >

< td colspan = 3  width = " 75% " >
        
< asp:TextBox ID = " txtTitle "  runat = " server "  Width = " 90% " ></ asp:TextBox >
td
>

调用:

< input ID = " btnClear "   class = " buttomw "  value = "  重置 "  onclick = " CheckInfo(); "  type = " button "   />


 

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值