Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
my js function is perfectly working (without master page) i just needed to use it on anther page so i copy paste it in a new web form but this time using master page and now it's not running at all..that's my code:

<%@ Page Title="" Language="vb" AutoEventWireup="false"  
MasterPageFile="~/MasterPage.Master" CodeBehind="homecarecontent.aspx.vb"  
 Inherits="homecare_web2.homecarecontent" %>
 <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<head>
<title></title>
<link href="StyleSheet1.css" rel="stylesheet" type="text/css" />
<style type="text/css">
    #TextArea1
    {
        height: 152px;
        width: 222px;
    }
    #conte
    {
        height: 136px;
        width: 229px;
    }
    #content_txt
    {            height: 178px;
        width: 226px;
    }
    #content_t
    {
        height: 159px;
        width: 225px;
    }
</style>
<script type="text/javascript">
    function limiter() {
        var area = document.getElementById("content_txt");
        var message = document.getElementById("message");
        var maxLength = 160;
        var checkLength = function () {
            if (area.value.length <= maxLength) {
                message.innerHTML = (maxLength - area.value.length) + " characters remainging";
            }
        }
        setInterval(checkLength, 300);
    }
  </script>

 </head>

and that's my asp code:

<td valign='top'>
                <textarea style="resize:none; margin-bottom:0px;" id="content_txt" class="area"
                    name="TextArea1"  runat="server" maxlength="160"  önkeyup="return limiter();" ></textarea>
            </td>


the error firefox console is that the area is null... but in reality it's not null !

any help plz !
Posted

JavaScript
var area = document.getElementById('<%=content_txt.ClientID%>');
var message = document.getElementById('<%=message%>');
 
Share this answer
 
v2
when we do use master pages id of control changes thats why it is not able to find the elements on the page and not working and resulting errors

C#
var area = document.getElementById("content_txt");
      var message = document.getElementById("message");
 
Share this answer
 
Comments
Jocelyne El Khoury 5-Sep-13 8:37am    
ok so what shall i do?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900