开发者

why javascript not work on masterpage

work on asp.net vs 05 C#.Master page header contain the bellow code

<script type="text/javascript" language="javascript" src="JScript.js"></script>

from my one page i call the javascript method

 <asp:TextBox ID="txtLength" runat="server" >0</asp:TextBox>

 <asp:TextBox ID="txtHeight" runat="server" onchange="javascript:DoChange();">0</asp:TextBox>

javascript method is below :

 {
      alert("hello world");**//get this alert but don't get the bellow alert.**
     var a=document.getElementById("txtL开发者_高级运维ength");
     var b=document.getElementById("txtHeight");
      alert(a.value*b.value);
   }

want to show value on message box .Actually want to calculate the Sft,How to ?


The DOM ID of the text boxes is not the same as the server side asp.net ID. In order to get the client DOM ID, use the ClientID property:

 var a=document.getElementById("<%= txtLength.ClientID %>");
 var b=document.getElementById("<%= txtHeight.ClientID %>");

Also, you are attempting to multiply two strings together even if that works.

More generally, I recommend using a javascript debugger like Firebug or Chrome's debugger. Then you will be able to see precisely what line the errors are occurring on and what they are.


Kindly refer to the below link

http://social.msdn.microsoft.com/Forums/en/netfxjscript/thread/dc7c1aa6-7571-460c-b039-13cdba8c396c

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜