This solution will help you use asp Text box and a Label to display the count of characters,
Add below code on your Default.aspx,
<asp:TextBox ID="txtComments" runat="server" TextMode="MultiLine"
MaxLength="160" ></asp:TextBox>
<asp:Label ID="lblCharacters" runat="server"></asp:Label>
Add below javascript code on your default.aspx,
<script language="javascript" type="text/javascript">
function DisplayCount()
{
var length = document.getElementById('<%=txtComments.ClientID%>').value.length;
document.getElementById('<%=lblCharacters.ClientID%>').innerText = length;
}
</script>
Add following code on your Page_load event,
txtComments.Attributes.Add("onkeypress", "javascript:return DisplayCount();");
After adding above code, you can see the count on the label when you type in the textbox.
The .NET Framework allows developers to use the same set of skills to rapidly buid great applications for the web, windows, services and more.
Display Textbox count on a Label
Disable Right click on web page
How to disable right click on web page or If you want to protect your source code or many times programmers may need to disable right click on web page. You can copy below script code in between <head> and </head> tag.
<script type="text/javascript">
var message="You Can't right click on this page!";
function clickIE()
{
if (event.button==2)
{
alert(message);
return false;
}
}
if (document.all&&!document.getElementById)
{
document.onmousedown=clickIE;
}
document.oncontextmenu=new Function("alert(message);return false")
</script>
Subscribe to:
Posts (Atom)