Get absolute path on tinymce Editor Control

Posted by Venkat | Labels:

Here we are going to discuss how to get the absolute path of the image or link on tinyMCE Editor contorl , by default it took relative path of the image so here it line you have to include on your script of your page.

relative_urls: false,

Watermark the textbox using javascript

Posted by Venkat | Labels: ,

Hi , Now we have to discuss about the watermark the textbox using javascript

for that you have to use onblur and onfocus property of your textbox


<script type = "text/javascript">

var defaultText = "Enter your text here";

function WaterMark(txt, evt)

{

if(txt.value.length == 0 && evt.type == "blur")

{

txt.style.color = "gray";

txt.value = defaultText;

}

if(txt.value == defaultText && evt.type == "focus")

{

txt.style.color = "black";

txt.value="";

}

}

</script>


Here is the HTML Code of the Textbox control

<asp:TextBox ID="TextBox1" runat="server" Text = "Enter your text here"

ForeColor = "Gray" onblur = "WaterMark(this, event);"

onfocus = "WaterMark(this, event);">

</asp:TextBox>

Now we have to write the attributes through code on your Page_load Event

TextBox1.Attributes.Add("onblur", "WaterMark(this, event);")

TextBox1.Attributes.Add("onfocus", "WaterMark(this, event);")

Textbox should allow minimum 5 Character

Posted by Venkat | Labels: ,

Hi Use this code.


<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator
ID="valUserName" runat="server" ControlToValidate="TextBox1"
Display="Dynamic" ErrorMessage="Minimum length 6 characters"
ForeColor="" ValidationExpression=".{6}.*" ></asp:RegularExpressionValidator>

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>

How to Detect the user Close the page

Posted by Venkat | Labels:

You can use the onunload or the onbeforeunload events to execute codes when the browser is about to closed.

You may also use Page Methods, see below

http://aspalliance.com/1294_CodeSnip_Handle_Browser_Close_Event_on_the_ServerSide.all

The code below will simulates the closed button of the browser when the user invoked the button and display an alert message..

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function doSomething()
{
alert('Widnow is about to close');
}
</script>

</head>
<body onunload="doSomething();">
<form id="form1" runat="server">

</form>
</body&gt;

Small trick to hide HTML element

Posted by Venkat | Labels:

In this post I’m going to only show a simple trick how to hide an image by using XPath expression and by not adding “server side” code into codebehind or inside a server side script block. I got this simple idea from a post I recently answered on the ASP.Net forum. Maybe some other may find this useful.


<img runat="server" visible='<%# (XPath("@value") == "35" ) %>' src='<%# "images/" + XPath("@img") + ".gif" %>'>


The XPath expression for the @value attribute will return true if the value is 35, if not it will return false. The visible attribute that is added to the img element, can only hide an element if it’s turned into a html server control. That is done by adding the runat attribute.


Ref: http://fredrik.nsquared2.com/ViewPost.aspx?PostId=324

PayOffers.in