Pages

Friday, 31 May 2013

How To Make setInterval() Function Example in JavaScript Using jQuery in C# Asp.Net

 How To Make setInterval() Function Example in JavaScript Using jQuery in C# Asp.Net

Program:

.Aspx File:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> setInterval</title>
<script type="text/javascript">
    var count = 0;
    function changeColor() {
        // Call function with 500 milliseconds gap
        setInterval(starttimer, 500);
    }
    function starttimer() {
        count += 1;
        var oElem = document.getElementById("divtxt");
        oElem.style.color = oElem.style.color == "red" ? "blue" : "red";
        document.getElementById("lbltxt").innerHTML = "Your Time Starts: " + count;
    }
</script>
</head>
<body>
<div id="divtxt">
<label id="lbltxt"style="font:bold 24px verdana" />
</div>
<button onclick="changeColor();">Start Timer</button>
</body>
</html>

Live Demo:

setInterval

How To Make jQuery setTimeout() Function Example Using JavaScript in C# Asp.Net

 How To Make jQuery setTimeout() Function Example Using JavaScript in C# Asp.Net


Program:

.Aspx File:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JavaScript display current time on webpage</title>
<script type="text/javascript">
function ShowCurrentTime() {
var dt = new Date();
document.getElementById("lblTime").innerHTML = dt.toLocaleTimeString();
setTimeout("ShowCurrentTime()", 1000); // Here 1000(milliseconds) means one 1 Sec
}
</script>
</head>
<body onload="ShowCurrentTime()">
<div>
JavaScript Display current time second by second:
<label id="lblTime" style=" font-weight:bold"></label>
</div>
</body>
</html>

Live Demo:

JavaScript display current time on webpage
JavaScript Display current time second by second:

How To Make SQL Server Check if String Contains Specific Word / String with CHARINDEX Function in C# Asp.Net

How To Make SQL Server Check if String Contains Specific Word / String with CHARINDEX Function in C# Asp.Net


CHARINDEX Function

This function is used to search for specific word or substring in overall string and returns its starting position of match. In case if no word found then it will return 0 (zero).


CHARINDEX ( StringToFind ,OverAllStringToSearch [ , start_location ] )

Example 1:


DECLARE @str VARCHAR(250)
SET @str='Welcome to fantasyaspnet.blogspot.in'
SELECT CHARINDEX('fantasyaspnet.blogspot.in',@str)

Output:

---------------------------------------
12
(1 row(s) affected)

How to Get Screen Resolution of User or Client Machine Using JavaScript in c# Asp.Net

How to Get Screen Resolution of User or Client Machine Using JavaScript in c# Asp.Net


Program:

.Aspx File:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Get Screen Resolution using JavaScript</title>
<script type="text/javascript" language="javascript">
function GetResolution(){
document.getElementById("txtWidth").value = screen.width;
document.getElementById("txtHight").value = screen.height;
}
</script>
</head>
<body onload="GetResolution();">
<table>
<tr><td align="center" colspan="2">
<b><span style="color: #990000;">Your Screen Resolution </span></b></td></tr>
<tr>
<td>Width :</td>
<td valign="middle"><input type="text" size="5" name="txtWidth" id="txtWidth">px</td>
</tr>
<tr>
<td>Height :</td>
<td valign="middle"><input type="text" size="5" name="txtHight" id="txtHight">px</td>
</tr>
</table>
</body>
</html>

Live Demo:

Get Screen Resolution using JavaScript
Your Screen Resolution
Width : px
Height : px

Thursday, 30 May 2013

How To Find Number of Vowels in a String in JavaScript OR Count Vowels in String using JavaScript C# Asp.Net

How To Find Number of Vowels in a String in JavaScript OR Count Vowels in String using JavaScript C# Asp.Net


Program:

.Aspx File:

<html>
<head>
<title>find number of vowels in a string in JavaScript</title>
<script type="text/javascript">
    function GetVowels() {
        var str = document.getElementById('txtname').value;
        var count = 0, total_vowels = "";
        for (var i = 0; i < str.length; i++) {
            if (str.charAt(i).match(/[a-zA-Z]/) != null) {
                // findVowels
                if (str.charAt(i).match(/[aeiouAEIOU]/)) {
                    total_vowels = total_vowels + str.charAt(i);
                    count++;
                }
            }
        }
        document.getElementById('vowels').value = total_vowels;
        document.getElementById('vcount').value = count;
    }
</script>
</head>
<body>
<div >
<table border="1px" cellspacing="0" width="30%" style="background-color: #B52025; color:White">
<tr><td colspan="2" align="center"><b>Get Vowels from String</b></td></tr>
<tr>
<td>Enter Text :</td>
<td><input type='text' id='txtname' /></td>
</tr>
<tr>
<td>Vowels Count :</td>
<td><input type='text' readonly="readonly" id='vcount'/></td>
</tr>
<tr>
<td>Total Vowels :</td>
<td><input type='text' readonly="readonly" id='vowels' /></td>
</tr>
<tr>
<td></td>
<td><input type='button' value='Get Vowels Count' onclick="javascript:GetVowels();" /></td>
</tr>
</table>
</div>
</body>
</html>

Live Demo:

find number of vowels in a string in JavaScript
Get Vowels from String
Enter Text :
Vowels Count :
Total Vowels :

How To Automatically Move Cursor to Next Field When Text box Full Using JavaScript in C# Asp.Net

 How To Automatically Move Cursor to Next Field When Text box Full Using JavaScript in C# Asp.Net


Program:

.Aspx File:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JavaScript to automatically move from one field to another field</title>
<script type="text/javascript">
    function movetoNext(current, nextFieldID) {
        if (current.value.length >= current.maxLength) {
            document.getElementById(nextFieldID).focus();
        }
    }
</script>
</head>
<body>
<b>Enter your Text:</b>
<input type="text" id="first" size="4" onkeyup="movetoNext(this, 'second')" maxlength="3" />
<input type="text" id="second" size="4" onkeyup="movetoNext(this, 'third')" maxlength="3" />
<input type="text" id="third" size="5" maxlength="4" />
</body>
</html>

Live Demo:
JavaScript to automatically move from one field to another field Enter your Text:

How To Remove Special Characters from Text box Using JavaScript in C# Asp.Net

How To  Remove Special Characters from Text box Using JavaScript in C# Asp.Net


Program:

.Aspx File:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Remove Special Characters from the Textbox using JavaScript</title>
<script language="javascript" type="text/javascript">
    function RemoveSpecialChar(txtName) {
        if (txtName.value != '' && txtName.value.match(/^[\w ]+$/) == null) {
            txtName.value = txtName.value.replace(/[\W]/g, '');
        }
    }
</script>
</head>
<body>
<div>
<b>Enter Text:</b><input id="txtName"  type="text" onkeyup="javascript:RemoveSpecialChar(this)" />
</div>
</body>
</html>

Live Demo:

Remove Special Characters from the Textbox using JavaScript
Enter Text:

How To Show Number of Characters Remaining in Text box or Text area Using JavaScript in C# Asp.Net

How To Show Number of Characters Remaining in Text box or Text area Using JavaScript in C# Asp.Net


Program:

.Aspx File:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Limit the number of characters in textbox or textarea</title>
<script type="text/javascript">
    function LimtCharacters(txtMsg, CharLength, indicator) {
        chars = txtMsg.value.length;
        document.getElementById(indicator).innerHTML = CharLength - chars;
        if (chars > CharLength) {
            txtMsg.value = txtMsg.value.substring(0, CharLength);
        }
    }
</script>
</head>
<body>
<div style="font-family:Verdana; font-size:13px">
Number of Characters Left:
<label id="lblcount" style="background-color:#E2EEF1;color:Red;font-weight:bold;">140</label><br/>
<textarea id="mytextbox" rows="5" cols="25" onkeyup="LimtCharacters(this,140,'lblcount');"></textarea>
</div>
</body>
</html>

Live Demo


Limit the number of characters in textbox or textarea
Number of Characters Left:

How To Disable Drag and Drop Option in Text box or Text area Controls in C# Asp.Net

How To Disable Drag and Drop Option in Text box or Text area Controls in C# Asp.Net


Program:

.Aspx File:

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

<html>
<head>
</head>
<body ondragstart="return false" draggable="false">
<b>Try to Drag and Drop Text Here :</b> <input type="text" name="txt" id="txtname" />
</body>
</html>

Live Demo:

Try to Drag and Drop Text Here :

How To Add / Remove CSS Class Dynamically to DIV Elements Using jQuery in c# Asp.net

How To Add / Remove CSS Class Dynamically to DIV Elements Using jQuery in c# Asp.net


Program:

.Aspx File:

<!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>
<title>jQuery Add Remove CSS Classes Dynamically</title>
<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $('#btnaddCSS').click(function () {
            $('#divsample').addClass('divclass')
        });
        $('#btnRemoveCSS').click(function () {
            $('#divsample').removeClass('divclass')
        });
    })
</script>
<style type="text/css">
.divclass
{
background-color:#B52025;
color:White;
width:30%;
}
</style>
</head>
<body>
<div id="divsample">
<h4>jQuery Add or Remove CSS Classes</h4>
<p>Welcome to fantasyaspnet.blogspot.in <br /><br/>It will provide different kind .Net related articles</p>
</div>
<div>
<input type="button" id="btnaddCSS" value="Add CSS Class" />
<input type="button" id="btnRemoveCSS" value="Remove CSS Class" />
</div>
</body>
</html>

Live Demo:

jQuery Add Remove CSS Classes Dynamically

jQuery Add or Remove CSS Classes

Welcome to fantasyaspnet.blogspot.in

It will provide different kind .Net related articles

How To Upload Files to Database in Asp.net Download Files From Database in SQL Server in c# And VB

How To Upload Files to Database in Asp.net Download Files From Database in SQL Server in c# And VB


Program:

.Aspx File:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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 id="Head1">
<title>Upload Word Files to Database and Download files from database in asp.net
</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FileUpload ID="fileUpload1" runat="server" /><br />
<asp:Button ID="btnUpload" runat="server" Text="Upload" onclick="btnUpload_Click" />
</div>
<div>
<asp:GridView ID="gvDetails" runat="server" AutoGenerateColumns="false" DataKeyNames="Id">
<HeaderStyle BackColor="#B52025" Font-Bold="true" ForeColor="White" />
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" />
<asp:BoundField DataField="FileName" HeaderText="FileName" />
<asp:TemplateField HeaderText="FilePath">
<ItemTemplate>
<asp:LinkButton ID="lnkDownload" runat="server" Text="Download" OnClick="lnkDownload_Click"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html

C# .CS File

using System;
using System.Data.SqlClient;
using System.IO;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    string strCon = "Data Source=SURANI-PC\\SQLEXPRESS;Initial Catalog=demo;Integrated Security=True";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindGridviewData();
        }
    }
    // Bind Gridview Data
    private void BindGridviewData()
    {
        using (SqlConnection con=new SqlConnection(strCon))
        {
            using (SqlCommand cmd=new SqlCommand())
            {
                cmd.CommandText = "select * from FileInformation";
                cmd.Connection = con;
                con.Open();
                gvDetails.DataSource = cmd.ExecuteReader();
                gvDetails.DataBind();
                con.Close();
            }
        }
     }
    // Save files to Folder and files path in database
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        string filename = Path.GetFileName(fileUpload1.PostedFile.FileName);
        Stream str = fileUpload1.PostedFile.InputStream;
        BinaryReader br = new BinaryReader(str);
        Byte[] size = br.ReadBytes((int) str.Length);
        using (SqlConnection con=new SqlConnection(strCon))
        {
            using (SqlCommand cmd=new SqlCommand())
            {
                cmd.CommandText = "insert into FileInformation(FileName,FileType,FileData) values(@Name,@Type,@Data)";
                cmd.Parameters.AddWithValue("@Name", filename);
                cmd.Parameters.AddWithValue("@Type", "application/word");
                cmd.Parameters.AddWithValue("@Data", size);
                cmd.Connection =con;
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
                BindGridviewData();  
            }
        }
    }
    // This button click event is used to download files from gridview
    protected void lnkDownload_Click(object sender, EventArgs e)
    {
        LinkButton lnkbtn = sender as LinkButton;
        GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
        int fileid = Convert.ToInt32(gvDetails.DataKeys[gvrow.RowIndex].Value.ToString());
        string name, type;
        using (SqlConnection con=new SqlConnection(strCon))
        {
            using (SqlCommand cmd=new SqlCommand())
            {
                cmd.CommandText = "select FileName, FileType, FileData from FileInformation where Id=@Id";
                cmd.Parameters.AddWithValue("@id", fileid);
                cmd.Connection = con;
                con.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                if(dr.Read())
                {
                    Response.ContentType = dr["FileType"].ToString();
                    Response.AddHeader("Content-Disposition", "attachment;filename=\"" +dr["FileName"] + "\"");
                    Response.BinaryWrite((byte[])dr["FileData"]);
                    Response.End();
                }
            }
        }
    }
}

VB

Imports System.Data.SqlClient
Imports System.IO
Imports System.Web.UI.WebControls
Partial Class VBCode
    Inherits System.Web.UI.Page
    Private strCon As String = "Data Source=SURANI-PC\\SQLEXPRESS;Initial Catalog=demo;Integrated Security=True"
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        If Not IsPostBack Then
            BindGridviewData()
        End If
    End Sub
    ' Bind Gridview Data
    Private Sub BindGridviewData()
        Using con As New SqlConnection(strCon)
            Using cmd As New SqlCommand()
                cmd.CommandText = "select * from FileInformation"
                cmd.Connection = con
                con.Open()
                gvDetails.DataSource = cmd.ExecuteReader()
                gvDetails.DataBind()
                con.Close()
            End Using
        End Using
    End Sub
    ' Save files to Folder and files path in database
    Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim filename As String = Path.GetFileName(fileUpload1.PostedFile.FileName)
        Dim str As Stream = fileUpload1.PostedFile.InputStream
        Dim br As New BinaryReader(str)
        Dim size As [Byte]() = br.ReadBytes(CInt(str.Length))
        Using con As New SqlConnection(strCon)
            Using cmd As New SqlCommand()
                cmd.CommandText = "insert into FileInformation(FileName,FileType,FileData) values(@Name,@Type,@Data)"
                cmd.Parameters.AddWithValue("@Name", filename)
                cmd.Parameters.AddWithValue("@Type", "application/word")
                cmd.Parameters.AddWithValue("@Data", size)
                cmd.Connection = con
                con.Open()
                cmd.ExecuteNonQuery()
                con.Close()
                BindGridviewData()
            End Using
        End Using
    End Sub
    ' This button click event is used to download files from gridview
    Protected Sub lnkDownload_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim lnkbtn As LinkButton = TryCast(sender, LinkButton)
        Dim gvrow As GridViewRow = TryCast(lnkbtn.NamingContainer, GridViewRow)
        Dim fileid As Integer = Convert.ToInt32(gvDetails.DataKeys(gvrow.RowIndex).Value.ToString())
        Dim name As String, type As String
        Using con As New SqlConnection(strCon)
            Using cmd As New SqlCommand()
                cmd.CommandText = "select FileName, FileType, FileData from FileInformation where Id=@Id"
                cmd.Parameters.AddWithValue("@id", fileid)
                cmd.Connection = con
                con.Open()
                Dim dr As SqlDataReader = cmd.ExecuteReader()
                If dr.Read() Then
                    Response.ContentType = dr("FileType").ToString()
                    Response.AddHeader("Content-Disposition", "attachment;filename=""" & Convert.ToString(dr("FileName")) & """")
                    Response.BinaryWrite(DirectCast(dr("FileData"), Byte()))
                    Response.[End]()
                End If
            End Using
        End Using
    End Sub
End Class

Demo:


How To Upload Files to Database in Asp.net Download Files From Database in SQL Server in c# And VB
How To Upload Files to Database in Asp.net Download Files From Database in SQL Server in c# And VB

How To Make Google Currency Converter JSON API Example Using jQuery in c# And VB Asp.net

How To Make Google Currency Converter JSON API Example Using jQuery in c# And VB Asp.net


Program:

.Aspx File:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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>
    <title>Google Currency Conversion</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
  <script type="text/javascript">
      $(function() {
      $('#btnConvert').click(function() {
          var amount = $('#txtAmount').val();
          var from = $('#ddlfrom').val();
          var to = $('#ddlto').val();
              $.ajax({ type: "POST",
              url: "WebService.asmx/CurrencyConversion",
                  data: "{amount:" + amount + ",fromCurrency:'" + from + "',toCurrency:'" + to + "'}",
                  contentType: "application/json; charset=utf-8",
                  dataType: "json",
                  success: function(data) {
                  $('#currency_converter_result').html(data.d);
                  }
              });
          });
      });
  </script>

</head>
<body>
    <form id="form1" runat="server">
    <table>
    <tr><td align="right">Enter Amount:</td><td>  <input id="txtAmount" maxlength="12" size="5" value="1" /></td></tr>
    <tr><td align="right">From:</td><td>
        <select id="ddlfrom">
            <option value="AED">United Arab Emirates Dirham (AED)</option>
            <option value="ANG">Netherlands Antillean Guilder (ANG)</option>
            <option value="ARS">Argentine Peso (ARS)</option>
            <option value="AUD">Australian Dollar (AUD)</option>
            <option value="BDT">Bangladeshi Taka (BDT)</option>
            <option value="BGN">Bulgarian Lev (BGN)</option>
            <option value="BHD">Bahraini Dinar (BHD)</option>
            <option value="BND">Brunei Dollar (BND)</option>
            <option value="BOB">Bolivian Boliviano (BOB)</option>
            <option value="BRL">Brazilian Real (BRL)</option>
            <option value="BWP">Botswanan Pula (BWP)</option>
            <option value="CAD">Canadian Dollar (CAD)</option>
            <option value="CHF">Swiss Franc (CHF)</option>
            <option value="CLP">Chilean Peso (CLP)</option>
            <option value="CNY">Chinese Yuan (CNY)</option>
            <option value="COP">Colombian Peso (COP)</option>
            <option value="CRC">Costa Rican Colón (CRC)</option>
            <option value="CZK">Czech Republic Koruna (CZK)</option>
            <option value="DKK">Danish Krone (DKK)</option>
            <option value="DOP">Dominican Peso (DOP)</option>
            <option value="DZD">Algerian Dinar (DZD)</option>
            <option value="EEK">Estonian Kroon (EEK)</option>
            <option value="EGP">Egyptian Pound (EGP)</option>
            <option value="EUR">Euro (EUR)</option>
            <option value="FJD">Fijian Dollar (FJD)</option>
            <option value="GBP">British Pound Sterling (GBP)</option>
            <option value="HKD">Hong Kong Dollar (HKD)</option>
            <option value="HNL">Honduran Lempira (HNL)</option>
            <option value="HRK">Croatian Kuna (HRK)</option>
            <option value="HUF">Hungarian Forint (HUF)</option>
            <option value="IDR">Indonesian Rupiah (IDR)</option>
            <option value="ILS">Israeli New Sheqel (ILS)</option>
            <option value="INR">Indian Rupee (INR)</option>
            <option value="JMD">Jamaican Dollar (JMD)</option>
            <option value="JOD">Jordanian Dinar (JOD)</option>
            <option value="JPY">Japanese Yen (JPY)</option>
            <option value="KES">Kenyan Shilling (KES)</option>
            <option value="KRW">South Korean Won (KRW)</option>
            <option value="KWD">Kuwaiti Dinar (KWD)</option>
            <option value="KYD">Cayman Islands Dollar (KYD)</option>
            <option value="KZT">Kazakhstani Tenge (KZT)</option>
            <option value="LBP">Lebanese Pound (LBP)</option>
            <option value="LKR">Sri Lankan Rupee (LKR)</option>
            <option value="LTL">Lithuanian Litas (LTL)</option>
            <option value="LVL">Latvian Lats (LVL)</option>
            <option value="MAD">Moroccan Dirham (MAD)</option>
            <option value="MDL">Moldovan Leu (MDL)</option>
            <option value="MKD">Macedonian Denar (MKD)</option>
            <option value="MUR">Mauritian Rupee (MUR)</option>
            <option value="MVR">Maldivian Rufiyaa (MVR)</option>
            <option value="MXN">Mexican Peso (MXN)</option>
            <option value="MYR">Malaysian Ringgit (MYR)</option>
            <option value="NAD">Namibian Dollar (NAD)</option>
            <option value="NGN">Nigerian Naira (NGN)</option>
            <option value="NIO">Nicaraguan Córdoba (NIO)</option>
            <option value="NOK">Norwegian Krone (NOK)</option>
            <option value="NPR">Nepalese Rupee (NPR)</option>
            <option value="NZD">New Zealand Dollar (NZD)</option>
            <option value="OMR">Omani Rial (OMR)</option>
            <option value="PEN">Peruvian Nuevo Sol (PEN)</option>
            <option value="PGK">Papua New Guinean Kina (PGK)</option>
            <option value="PHP">Philippine Peso (PHP)</option>
            <option value="PKR">Pakistani Rupee (PKR)</option>
            <option value="PLN">Polish Zloty (PLN)</option>
            <option value="PYG">Paraguayan Guarani (PYG)</option>
            <option value="QAR">Qatari Rial (QAR)</option>
            <option value="RON">Romanian Leu (RON)</option>
            <option value="RSD">Serbian Dinar (RSD)</option>
            <option value="RUB">Russian Ruble (RUB)</option>
            <option value="SAR">Saudi Riyal (SAR)</option>
            <option value="SCR">Seychellois Rupee (SCR)</option>
            <option value="SEK">Swedish Krona (SEK)</option>
            <option value="SGD">Singapore Dollar (SGD)</option>
            <option value="SKK">Slovak Koruna (SKK)</option>
            <option value="SLL">Sierra Leonean Leone (SLL)</option>
            <option value="SVC">Salvadoran Colón (SVC)</option>
            <option value="THB">Thai Baht (THB)</option>
            <option value="TND">Tunisian Dinar (TND)</option>
            <option value="TRY">Turkish Lira (TRY)</option>
            <option value="TTD">Trinidad and Tobago Dollar (TTD)</option>
            <option value="TWD">New Taiwan Dollar (TWD)</option>
            <option value="TZS">Tanzanian Shilling (TZS)</option>
            <option value="UAH">Ukrainian Hryvnia (UAH)</option>
            <option value="UGX">Ugandan Shilling (UGX)</option>
            <option value="USD">US Dollar (USD)</option>
            <option value="UYU">Uruguayan Peso (UYU)</option>
            <option value="UZS">Uzbekistan Som (UZS)</option>
            <option value="VEF">Venezuelan Bolívar (VEF)</option>
            <option value="VND">Vietnamese Dong (VND)</option>
            <option value="XOF">CFA Franc BCEAO (XOF)</option>
            <option value="YER">Yemeni Rial (YER)</option>
            <option value="ZAR">South African Rand (ZAR)</option>
            <option value="ZMK">Zambian Kwacha (ZMK)</option>
        </select></td>
       </tr>
       <tr> <td align="right">to:</td><td>
        <select id="ddlto">
            <option value="AED">United Arab Emirates Dirham (AED)</option>
            <option value="ANG">Netherlands Antillean Guilder (ANG)</option>
            <option value="ARS">Argentine Peso (ARS)</option>
            <option value="AUD">Australian Dollar (AUD)</option>
            <option value="BDT">Bangladeshi Taka (BDT)</option>
            <option value="BGN">Bulgarian Lev (BGN)</option>
            <option value="BHD">Bahraini Dinar (BHD)</option>
            <option value="BND">Brunei Dollar (BND)</option>
            <option value="BOB">Bolivian Boliviano (BOB)</option>
            <option value="BRL">Brazilian Real (BRL)</option>
            <option value="BWP">Botswanan Pula (BWP)</option>
            <option value="CAD">Canadian Dollar (CAD)</option>
            <option value="CHF">Swiss Franc (CHF)</option>
            <option value="CLP">Chilean Peso (CLP)</option>
            <option value="CNY">Chinese Yuan (CNY)</option>
            <option value="COP">Colombian Peso (COP)</option>
            <option value="CRC">Costa Rican Colón (CRC)</option>
            <option value="CZK">Czech Republic Koruna (CZK)</option>
            <option value="DKK">Danish Krone (DKK)</option>
            <option value="DOP">Dominican Peso (DOP)</option>
            <option value="DZD">Algerian Dinar (DZD)</option>
            <option value="EEK">Estonian Kroon (EEK)</option>
            <option value="EGP">Egyptian Pound (EGP)</option>
            <option value="EUR">Euro (EUR)</option>
            <option value="FJD">Fijian Dollar (FJD)</option>
            <option value="GBP">British Pound Sterling (GBP)</option>
            <option value="HKD">Hong Kong Dollar (HKD)</option>
            <option value="HNL">Honduran Lempira (HNL)</option>
            <option value="HRK">Croatian Kuna (HRK)</option>
            <option value="HUF">Hungarian Forint (HUF)</option>
            <option value="IDR">Indonesian Rupiah (IDR)</option>
            <option value="ILS">Israeli New Sheqel (ILS)</option>
            <option value="INR">Indian Rupee (INR)</option>
            <option value="JMD">Jamaican Dollar (JMD)</option>
            <option value="JOD">Jordanian Dinar (JOD)</option>
            <option value="JPY">Japanese Yen (JPY)</option>
            <option value="KES">Kenyan Shilling (KES)</option>
            <option value="KRW">South Korean Won (KRW)</option>
            <option value="KWD">Kuwaiti Dinar (KWD)</option>
            <option value="KYD">Cayman Islands Dollar (KYD)</option>
            <option value="KZT">Kazakhstani Tenge (KZT)</option>
            <option value="LBP">Lebanese Pound (LBP)</option>
            <option value="LKR">Sri Lankan Rupee (LKR)</option>
            <option value="LTL">Lithuanian Litas (LTL)</option>
            <option value="LVL">Latvian Lats (LVL)</option>
            <option value="MAD">Moroccan Dirham (MAD)</option>
            <option value="MDL">Moldovan Leu (MDL)</option>
            <option value="MKD">Macedonian Denar (MKD)</option>
            <option value="MUR">Mauritian Rupee (MUR)</option>
            <option value="MVR">Maldivian Rufiyaa (MVR)</option>
            <option value="MXN">Mexican Peso (MXN)</option>
            <option value="MYR">Malaysian Ringgit (MYR)</option>
            <option value="NAD">Namibian Dollar (NAD)</option>
            <option value="NGN">Nigerian Naira (NGN)</option>
            <option value="NIO">Nicaraguan Córdoba (NIO)</option>
            <option value="NOK">Norwegian Krone (NOK)</option>
            <option value="NPR">Nepalese Rupee (NPR)</option>
            <option value="NZD">New Zealand Dollar (NZD)</option>
            <option value="OMR">Omani Rial (OMR)</option>
            <option value="PEN">Peruvian Nuevo Sol (PEN)</option>
            <option value="PGK">Papua New Guinean Kina (PGK)</option>
            <option value="PHP">Philippine Peso (PHP)</option>
            <option value="PKR">Pakistani Rupee (PKR)</option>
            <option value="PLN">Polish Zloty (PLN)</option>
            <option value="PYG">Paraguayan Guarani (PYG)</option>
            <option value="QAR">Qatari Rial (QAR)</option>
            <option value="RON">Romanian Leu (RON)</option>
            <option value="RSD">Serbian Dinar (RSD)</option>
            <option value="RUB">Russian Ruble (RUB)</option>
            <option value="SAR">Saudi Riyal (SAR)</option>
            <option value="SCR">Seychellois Rupee (SCR)</option>
            <option value="SEK">Swedish Krona (SEK)</option>
            <option value="SGD">Singapore Dollar (SGD)</option>
            <option value="SKK">Slovak Koruna (SKK)</option>
            <option value="SLL">Sierra Leonean Leone (SLL)</option>
            <option value="SVC">Salvadoran Colón (SVC)</option>
            <option value="THB">Thai Baht (THB)</option>
            <option value="TND">Tunisian Dinar (TND)</option>
            <option value="TRY">Turkish Lira (TRY)</option>
            <option value="TTD">Trinidad and Tobago Dollar (TTD)</option>
            <option value="TWD">New Taiwan Dollar (TWD)</option>
            <option value="TZS">Tanzanian Shilling (TZS)</option>
            <option value="UAH">Ukrainian Hryvnia (UAH)</option>
            <option value="UGX">Ugandan Shilling (UGX)</option>
            <option value="USD">US Dollar (USD)</option>
            <option value="UYU">Uruguayan Peso (UYU)</option>
            <option value="UZS">Uzbekistan Som (UZS)</option>
            <option value="VEF">Venezuelan Bolívar (VEF)</option>
            <option value="VND">Vietnamese Dong (VND)</option>
            <option value="XOF">CFA Franc BCEAO (XOF)</option>
            <option value="YER">Yemeni Rial (YER)</option>
            <option value="ZAR">South African Rand (ZAR)</option>
            <option value="ZMK">Zambian Kwacha (ZMK)</option>
        </select></td></tr>
        <tr><td></td><td> <input id="btnConvert" type="button" value="Convert" /></td></tr>
    </table>
   <div style="overflow:hidden; padding:10px; width:500px; margin:10px; background:#B52025; border:solid 1px #ccc;">

    <div id="currency_converter_result" style="padding: 2px; margin: 5px; font-weight:bold; font-size:14pt">
    </div>
</div>
    </form>
</body>
</html>

C# .CS File

using System.Net;
using System.Text.RegularExpressions;
using System.Web.Services;


[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

[System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService
{
    [WebMethod]
    public string CurrencyConversion(decimal amount, string fromCurrency, string toCurrency)
    {
        WebClient web = new WebClient();
        string url = string.Format("http://www.google.com/ig/calculator?hl=en&q={2}{0}%3D%3F{1}", fromCurrency.ToUpper(), toCurrency.ToUpper(), amount);
        string response = web.DownloadString(url);
        Regex regex = new Regex(@":(?<rhs>.+?),");
        string[] arrDigits = regex.Split(response);
        string rate = arrDigits[3];
        return rate;
    }
}

VB

Imports System.Net
Imports System.Text.RegularExpressions
Imports System.Web.Services


<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
Public Class WebService2
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function CurrencyConversion(ByVal amount As Decimal, ByVal fromCurrency As String, ByVal toCurrency As String) As String
Dim web As New WebClient()
Dim url As String = String.Format("http://www.google.com/ig/calculator?hl=en&q={2}{0}%3D%3F{1}", fromCurrency.ToUpper(), toCurrency.ToUpper(), amount)
Dim response As String = web.DownloadString(url)
Dim regex As New Regex(":(?<rhs>.+?),")
Dim arrDigits As String() = regex.Split(response)
Dim rate As String = arrDigits(3)
Return rate
End Function
End Class


Demo:


How To Make Google Currency Converter JSON API Example Using jQuery in c# And VB Asp.net
How To Make Google Currency Converter JSON API Example Using jQuery in c# And VB Asp.net

Monday, 27 May 2013

How To Make Fancy Switch ON and OFF Effects Example Using jQuery in c# Asp.Net


How To Make Fancy Switch ON and OFF Effects Example Using jQuery in c# Asp.Net

Program:

.Aspx File:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Switch ON OFF</title>
<script src="http://code.jquery.com/jquery-1.8.2.js" type="text/javascript"></script>
<style type="text/css">
#container{background:#ebebeb;}
.switch{
border:none;
background:left no-repeat;
width:105px;
height:46px;
padding:0;
margin:0;
}
.on, .off{
width:50px;
height:40px;
display:inline-block;
cursor:pointer;
}
.result{display:none; margin-top:5px; font-size:14px; color:#333;}
.result span{color:#C03; font-weight:700;}
</style>
<script type="text/javascript">
    $(document).ready(function () {
        $('.switch').css('background', 'url("http://papermashup.com/demos/jquery-switch/switch.png")');
        $('.on_off').css('display', 'none');
        $('.on, .off').css('text-indent', '-10000px');
        $("input[name=on_off]").change(function () {
            var button = $(this).val();
            if (button == 'off') {
                $('.switch').css('background-position', 'right');
            }
            if (button == 'on') {
                $('.switch').css('background-position', 'left');
            }
            $('.result span').html(button);
            $('.result').fadeIn();
        });
    });
</script>
</head>
<body>
<form id="form1" runat="server">
<fieldset class="switch">
<label class="off">Off<input type="radio" class="on_off" name="on_off" value="off"/></label>
<label class="on">On<input type="radio" class="on_off" name="on_off" value="on"/></label>
</fieldset>
<input type="submit" value="Submit"/>
<div class="result">The switch is: <span>on</span></div>
</form>
</body>
</html>


Live Demo:

Switch ON OFF
The switch is: on

How To Make jQuery Floating Navigation Menu Scrolling OR jQuery Move Menu with Scroll of Web Page in Html And c# Asp.Net

How To Make jQuery Floating Navigation Menu Scrolling OR jQuery Move Menu with Scroll of Web Page in Html And c# Asp.Net


Program:

.Aspx File


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

<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Demo - Creating a Floating Navigation Menu</title>

  <!-- Include jQuery -->
  <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>

  <style type='text/css'>

   body {
   background-color: #FFF;
   <!--color: Black;-->
   font: 12px/1.4em Arial,sans-serif;
}
#wrap {
   margin: 10px auto;    
   background: #666;
   padding: 10px;
   width: 700px;
}
#header {
   background-color: #666;
   color: #FFF;
}
#logo {
   font-size: 30px;
   line-height: 40px;
   padding: 5px;
}
#navWrap {
   height: 30px;
}
#nav {
   padding: 5px;
   background: #999;
}
#nav ul {
   margin: 0;
   padding: 0;
}
#nav li {
   float: left;
   padding: 3px 8px;
   background-color: #B52025;
   margin: 0 10px 0 0;
   color: #FFF;
   list-style-type: none;
}
#nav li a {
   color: #FFF;
   text-decoration: none;
}
#nav li a:hover {
   text-decoration: underline;
}
br.clearLeft {
   clear: left;    
}​
  </style>

<script type='text/javascript'>
    //<![CDATA[

    $(function () {
        // Stick the #nav to the top of the window
        var nav = $('#nav');
        var navHomeY = nav.offset().top;
        var isFixed = false;
        var $w = $(window);
        $w.scroll(function () {
            var scrollTop = $w.scrollTop();
            var shouldBeFixed = scrollTop > navHomeY;
            if (shouldBeFixed && !isFixed) {
                nav.css({
                    position: 'fixed',
                    top: 0,
                    left: nav.offset().left,
                    width: nav.width()
                });
                isFixed = true;
            }
            else if (!shouldBeFixed && isFixed) {
                nav.css({
                    position: 'static'
                });
                isFixed = false;
            }
        });
    });

    //]]>
</script>

</head>
<body>
<form id="form1" runat="server">
<div id="wrap">
 
    <!-- The header code, including the menu -->
    <div id="header">
        <div id="logo">Start Slowly Scrolling Down<br /> This Page!</div>
        <div id="navWrap">
            <div id="nav">
                <ul>
                    <li><a href="#" class="smoothScroll">Demo Link 1</a></li>
                    <li><a href="#" class="smoothScroll">Demo Link 2</a></li>
                    <li><a href="#" class="smoothScroll">Demo Link 3</a></li>
                    <li><a href="#" class="smoothScroll">Demo Link 4</a></li>
                </ul>
                <br class="clearLeft" />
            </div>
        </div>
    </div>
 
    <!-- The main page content (just filler for this demo) -->
    <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
    <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
       <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
    <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
    <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
    <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
       <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
    <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
  <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
    <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
       <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
    <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
  <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
    <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
       <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
    <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
  <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
  <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
    <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
       <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
    <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
   <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
    <p>
    http://fantasyaspnet.blogspot.in/ offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies.
    </p>
</div>
   </form>
</body>
</html>

Demo:

for live demo check this site jQuery smooth scrolling floating Menu

How To Get Google Maps Api Key for Localhost Website in C# Asp.Net

How To Get Google Maps Api Key for Localhost Website in C# Asp.Net

First open the APIs Console page at https://code.google.com/apis/console and log in with your Google Account. Whenever you open above url it will show like as shown below


How To Get Google Maps Api Key for Localhost Website in C# Asp.Net
How To Get Google Maps Api Key for Localhost Website in C# Asp.Net

Now click on Create project once login click on the Services link from the left-hand menu.


Once open Services tab check for Google Maps API v3 and click on “off” to activate that service in the next screen select conditions and click “Accept” button.


Now Click on API Access link from the left-hand menu. Once if it opens Your API key is available from the API Access page, in the Simple API Access section. In that Maps API applications click on Create new Browser key button >> in next window give url of your application and click Create



How To Get Google Maps Api Key for Localhost Website in C# Asp.Net
How To Get Google Maps Api Key for Localhost Website in C# Asp.Net

How To Add Google Map in Asp.net Website OR Integrate Google Map in Website using JavaScript in C# Asp.Net

How To Add Google Map in Asp.net Website | Integrate Google Map in Website using JavaScript  in C# Asp.Net

To add Google map to asp.net website check below article

How To Integrate Google Map in Website or Show Google Map in Website using JavaScript in html and C# asp.net

How To Integrate Google Map in Website or Show Google Map in Website using JavaScript in html and C# asp.net


Program:

.Aspx File


<!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>
<title>Show or Integrate Google Maps in asp.net webapplication</title>
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC6v5-2uaq_wusHDktM9ILcqIrlPtnZgEk&sensor=false">
</script>
<script type="text/javascript">
    function initialize() {
        var myLatlng = new google.maps.LatLng(-34.397, 150.644)
        var mapOptions = {
            center: myLatlng,
            zoom: 8,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            marker: true
        };
        var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
    }
</script>

</head>
<body onload="initialize()">
<form id="form1" runat="server">
<div id="map_canvas" style="width: 500px; height: 300px"></div>
</form>
</body>
</html>

Demo:

How To Integrate Google Map in Website or Show Google Map in Website using JavaScript in html and C# asp.net
How To Integrate Google Map in Website or Show Google Map in Website using JavaScript in html and C# asp.net

Thursday, 23 May 2013

How To Add Marker in Google Map Api in Website Using JavaScript in c# Asp.Net

How To Add Marker in Google Map Api in Website Using JavaScript in c# Asp.Net


Program:

.Aspx File

<!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>
<title>Show or Add markers to Google Maps in asp.net website</title>
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC6v5-2uaq_wusHDktM9ILcqIrlPtnZgEk&sensor=true">
</script>
<script type="text/javascript">
    function initialize() {
        var myLatlng = new google.maps.LatLng(-34.397, 150.644)
        var mapOptions = {
            center: myLatlng,
            zoom: 8,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            marker: true
        };
        var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
        var marker = new google.maps.Marker({
            position: myLatlng,
            map: map,
            title: "Your Location Address!"
        });
        marker.setMap(map);
    }
</script>

</head>
<body onload="initialize()">
<form id="form1" runat="server">
<div id="map_canvas" style="width: 500px; height: 300px"></div>
</form>
</body>
</html>

Demo:

How To Add Marker in Google Map Api in Website Using JavaScript in c# Asp.Net
How To Add Marker in Google Map Api in Website Using JavaScript in c# Asp.Net