Limit the Maximum number of Characters in the texbox

Posted by Venkat | Labels: , ,

Here is the code how to limit the no.of charater entered by the user in TextBox , mostly this can be implemented on Post comment , Feedback , Message board ...



This example demonstrates on how are we going to limit the number of characters to be typed into the TextBox using JavaScript and display the remaining characters in a Label Control.


<script type="text/javascript" language="javascript">

function validatelimit(obj, maxchar)
{

if(this.id) obj = this;

var remaningChar = maxchar - obj.value.length;
document.getElementById('<%= Label1.ClientID %>').innerHTML = remaningChar;

if( remaningChar <= 0)
{
obj.value = obj.value.substring(maxchar,0);
alert('Character Limit exceeds!');
return false;

}
else
{return true;}
}

</script>

<body runat="server">
<form id="form1" runat="server">

<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" onkeyup="validatelimit(this,300)"> </asp:TextBox>
<asp:Label ID="Label1" runat="server" Text="0"></asp:Label>

</form>

</body>
Note: 300 is the MAX length of the characters in the TextBox..Just change the value of 300 based on your requirements..

Clear all the control values in webpage

Posted by Venkat | Labels:

Here is the code to clear all the control values in the page. this function should call on Reset button Click event.


private void ResetFormValues(Control parent)
{
foreach (Control c in parent.Controls)
{
if (c.Controls.Count > 0)
{
ResetFormValues(c);
}
else
{
switch(c.GetType().ToString())
{
case "System.Web.UI.WebControls.TextBox":
((TextBox)c).Text = "";
break;
case "System.Web.UI.WebControls.CheckBox":
((CheckBox)c).Checked = false;
break;
case "System.Web.UI.WebControls.RadioButton":
((RadioButton)c).Checked = false;
break;

}
}
}
}

The same you can do it on JAVASCRIPT

Ex:

<input id="Button1" type='button' onclick='ClearAllControls()' value='Clear All Controls Using Javascript' />


<script language="javascript" type='text/javascript'>
function ClearAllControls() {
for (i = 0; i <>
doc = document.forms[0].elements[i];
switch (doc.type) {
case "text":
doc.value = "";
break;
case "checkbox":
doc.checked = false;
break;
case "radio":
doc.checked = false;
break;
case "select-one":
doc.options[doc.selectedIndex].selected = false;
break;
case "select-multiple":
while (doc.selectedIndex != -1) {
indx = doc.selectedIndex;
doc.options[indx].selected = false;
}
doc.selected = false;
break;
default:
break;
}
}
}
</script>

Editor controls

Posted by Venkat | Labels: ,

There are so many free editor controls Avaliable for .net control

http://www.freetextbox.com/
http://tinymce.moxiecode.com/
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/HTMLEditor/HTMLEditor.aspx
I will post the each editor controls ,like how to declare and use it on ASP.NET etc..
Shortly...,

Installation of Freetexbox control

http://www.a2zdotnet.com/View.aspx?id=28
This is the Initialization of TinyMCE Editor control and you can also the downlaod the support folder

http://www.dotnetspider.com/resources/27037-TinyMCE-Editor-Control.aspx

Number of way pass the data between Webpages

Posted by Venkat | Labels:

Here is the link i have given , which shows the no. of way to pass the data between page like session,Querystring, Cross page Posting , etc..

http://dotnetslackers.com/Community/blogs/haissam/archive/2007/11/26/ways-to-pass-data-between-webforms.aspx

http://www.dotnetbips.com/articles/c585b4d3-93c5-4c66-9d49-8e1946f4d311.aspx

I will post the workout code shortly..,

Jump Link within Page

Posted by Venkat | Labels:

Here is the code how to switch the view like top or bottom

for ex: we have seen on FAQ pages there if we click top it goes to top of the page the same functionality we have to implement.

<asp:HyperLink ID="top" runat="server" />

<br />asdsadasdsadsadadas<br />

<asp:HyperLink ID="bottom" runat="server" NavigateUrl="#top" Text="top" />

or

<a id="identifier"> </a>
<br />asdhsa<br />asdjksahd<br />

<a href="#identifier"> to top</a>

PayOffers.in