Tuesday, 25 December 2012

Remove all HTML tag in c#


Suppose  label named lblDescription have html tags. We can remove all html tags as following.

Input Data: <p>Test</p>

Output Data:  Test  ( No <p> tag )

 lblDescription.Text="<p>Test</p>"
string result = Regex.Replace(lblDescription.Text, @"<(.|\n)*?>", string.Empty);
 lblDescription.Text  = result.Trim();

Sunday, 16 December 2012

Regular expression for textbox accepting only alphabet and spaces only

Regular expression for textbox accepting only alphabet and spaces only:

^([a-zA-Z]+(_[a-zA-Z]+)*)(\s([a-zA-Z]+(_[a-zA-Z]+)*))*$

Wednesday, 12 December 2012

Count specific character occurances in string withou looping

To find the occurance of particular character without looping:

String TestString = "12345678901234567890";
Int32 Count = (TestString).Length - (TestString.Replace("9", "")).Length;


Above i want to find the occurance of "9"

Wednesday, 5 December 2012

Javascript code to get latitude and longitude for address

 Javascript code to get latitude and longitude for address

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

    <script type="text/javascript">

        var geocoder = new google.maps.Geocoder();
        var address = "New York";

        geocoder.geocode({ 'address': address }, function(results, status) {

            if (status == google.maps.GeocoderStatus.OK) {
                var latitude = results[0].geometry.location.lat();
                var longitude = results[0].geometry.location.lng();
                alert(latitude);
                alert(longitude);
            }
        });

   </script>

Function to return multiple values in SQL SERVER

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Function with input parameter and it will return table parameter(only one as function return only one parameter in this case it is table type)

Create FUNCTION MyTestFunction
(
@DataBaseTableColumn3 int
)
RETURNS @Dummytable TABLE
(
    MyColumn1 nvarchar(max),
    MyColumn2 nvarchar(max)
)
AS
Begin
    insert into @Dummytable(MyColumn1,MyColumn2)SELECT top 1 DataBaseTableColumn1,DataBaseTableColumn2 FROM DatabaseTable where DataBaseTableColumn3=@DataBaseTableColumn3
    RETURN
End

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Function without input parameter and it will return table parameter(only one as function return only one parameter in this case it is table type)

Create FUNCTION MyTestFunction
(

)
RETURNS @Dummytable TABLE
(
    MyColumn1 nvarchar(max),
    MyColumn2 nvarchar(max)
)
AS
Begin
    insert into @Dummytable(MyColumn1,MyColumn2)SELECT top 1 DataBaseTableColumn1,DataBaseTableColumn2 FROM DatabaseTable
    RETURN
End

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Monday, 3 December 2012

How To Use Text Over Images with HTML

<IMG SRC="newjoe03.jpg">
<DIV STYLE="position:absolute; top:250px; left:20px; width:200px; height:25px">
<CENTER><FONT SIZE="+2" COLOR="00ff00">Looking Into The Future</FONT></CENTER>
</DIV>



Use the link: http://www.htmlgoodies.com/tutorials/web_graphics/article.php/3480021/Text-Over-Images.htm