Friday 29 June 2012

Multiple markers in google map version 3


Click to add markers to the map





<html>

 <head>
   <title>Multiple Markers</title>

   <script type="text/javascript" 
     src="http://maps.googleapis.com/maps/api/js?
     key=YOUR-API-KEY&sensor=false">
   </script>

   <script type="text/javascript">
  
     var map;          

     function initialize()
     {

      var latlng = new google.maps.LatLng(24.20689,81.386719);

      var myOptions = {
      zoom: 2, 
      center: latlng, 
      mapTypeId: google.maps.MapTypeId.TERRAIN
      };

      map = new google.maps.Map
            (document.getElementById("map_canvas"), myOptions);
              
      google.maps.event.addListener(map, 'click',
       function(event)
       {
        addMarker(event.latLng);
       });
 
     }
    
     function addMarker(location) 
     {
      marker = new google.maps.Marker({
      position: location,
      map: map });
     }          

   </script>
 </head>

 <body onload="initialize()">    
    <div>
        <div id="map_canvas" style="width:450; height:450">
  </div>
    </div>  
 </body>

</html>

Wednesday 27 June 2012

How to use Google Map v3 in your site





InOrder to use Google Maps Version 3 you will need  a  Api key


To create your API key:
  1. Go to the link https://code.google.com/apis/console and log in with your Google Account.
  2. Click the Services menu from the left side
  3. Activate the Google Maps API v3 service.
  4. select the API Access  from the side. Your API key is available from the API Access page . This API key is used in  browser apps.


     once you have the key  you can use the following code to integrate the google maps
 version 3 in your site.


     Google has anounced a limitation on the usage of  google maps version 3, 25000 views
per day.If this limit is exceeded  you ll be charged. You need not worry unless your site 
has visitors in the thousands.


<html>
 <head>
    <title></title>  

    <style type="text/css">
        
        html { height: 100% }    
        body { height: 100%; margin: 0px; padding: 0px }    
        #map_canvas { height: 100% }  
        
    
    </style>

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

    <script type="text/javascript">
      function initialize() {
        var latlng = new google.maps.LatLng(-34.397, 150.644); 
        var myOptions = {zoom: 3, center: latlng, mapTypeId: 
        google.maps.MapTypeId.ROADMAP};
        var map = new google.maps.Map
       (document.getElementById("map_canvas"), myOptions);
     
    </script>

 </head>
  
 <body>  
    <div>
      <div id="map_canvas" style="height: 300; width: 300;">
      </div>
    </div>
 </body>
</html>

Tuesday 19 June 2012

Loading Xaml Dynamically in silverlight 4

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Text;
using System.Windows.Markup;

namespace slXamlLoad
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            
            string buttonxaml;
      
            StringBuilder sb1 = new StringBuilder();

            sb1.Append("<Button  xmlns='http://schemas.microsoft.com/client/2007'   Content='Button' Height='23' HorizontalAlignment='Left' Margin='10,10,0,0' Name='button1' VerticalAlignment='Top' Width='75' />");

            buttonxaml = sb1.ToString(0, sb1.Length);
            Button mybutton = XamlReader.Load(buttonxaml) as Button;

            LayoutRoot.Children.Add(mybutton);
            
        }
    }
}

                             
The Xaml Code for the above is as follows
<UserControl x:Class="slXamlLoad.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="315" d:DesignWidth="730">
    
    
       
    

Ajax-Drag Panel Extender


First  you  need  to  have  installed  Ajax Toolkit .For  details  on  how to install ajax toolkit in 
visual  studio  you  can  refer  the following  link.

http://www.dotnetstadium.com/2012/06/ajax-toolkit-installation.html

Step1


In order to use Ajax Drag Panel Extender you need to include the following javascript
in your Aspx page .




Step2


Also  you  need  to  include  the  script  manager  in the  aspx  page,this is to provide
support  for the ajax toolkit controls.




Step3


Now  you  can  add  the  DragPanelExtender  to  the  aspx page .


It  is  important  that  you  provide  the  TargetControlID , DragHandleID  Properties
for the DragPanelExtender.



Step4


You  need to  create  two  panels  one  inside  the  other.

As  you  can  see  the  TargetControlID  of the DragPanelExtender  is set to Panel1  and the
DragHandleID of it is set to Panel2.


Now  you  can  run  your  aspx  page  and  test  the  DragPanelExtender.


Friday 15 June 2012

How to use GridSplitter in Silverlight 4

Get Microsoft Silverlight


Step 1

  •    Add  a  grid  with  two  columns  and  two  rows   
  •     Here  i have not  specified  any  width  or  height  for  the rows and  columns  
so  the  height  and  width  of  the  Grid  will  be  divided  equally.




Step2

  •   Now  add  gridsplitters  to  each  column  and  row
  •   You  need  to  give  the  vertical ,horizontal  alignment ,Grid.Column and Grid.Row
correctly
  •   Grid.Column and Grid.Row  corresponds  to  which  column and  which row  the splitter  
goes in.




Step3

         Now  add  controls  inside  each  of  the  cell  in the  grid .I  have  added  four  calenders
in  my  application

   
      






















Ajax Toolkit Installation

Step1


Download  The  Latest  Version  of  Ajax  Control  ToolKit   From  the  following   link

http://ajaxcontroltoolkit.codeplex.com/releases/view/87024


Step2

You 'll  need  to  extract  the  files.


Step3

Create  a  web  application  in  Visual Studio

Now  go to the  toolbox window



Step4

Now  right  click  and  choose  Add  Tab



Step5

Rename  the  tab  as  you   like 



Step6

Now  Right  Click  on  The  tab  and  select  Choose Items from   the  Menu 




Step7

Ok , now  Browse  to the  folder  where  you  have  kept  the  extracted  files   and  choose 
the  AjaxControlToolkit.dll .





All  the  ajax toolkit  controls will  be loaded under  the newly created  tab





Ajax-Resizable Control Extender


First  u  need  to have  installed  Ajax toolkit  . If  u  have  not  installed  Ajax  toolkit  you  can  download it  from  the  following  link

http://www.asp.net/ajaxlibrary/download.ashx

you  can  check  out  the  following  post  on  how  to  install and  configure  ajax  tollkit


http://www.dotnetstadium.com/2012/06/ajax-toolkit-installation.html


First  you  need  to  create  the  following  style  in  your  aspx  page , the  .handleimage  class
will  be later  applied  to  the  ResizableControlExtender .





you  need  to put  a  script  manager on  the  aspx page ,this  is  to  support   the  ResizableControlExtender




The  script  tag   will  look  like  below
 



Now  create  a  panel  and  name  it as  panel1.

ok  now  let  us  add  the  ResizableControlExtender  You  can  find  it  under  the  tab in  which  u  configured  Ajax  toolkit









As  you  can  see  the  ResizableControlExtender 's  TargetControlID  is pointed  towards
panel1

we also  need to link the  HandleCssClass  to point  to  handleimage



The  Entire Asp will  look  like  below
















Wednesday 13 June 2012

Install Silverlight Xap as Windows Application

we will use a .bat file to install the .xap file as a windows application
 the contents of the .bat should be as follows

 
"C:\Program Files\Microsoft Silverlight\sllauncher.exe"
/install:C:\Users\subash\Desktop\ss\silverlight_xap_name.xap 
/origin:http://server:2011/Silverlight/silverlight_xap_name.xap
/shortcut:desktop+startmenu  /overwrite   


here  apart  from  the  local  path  of  the   xap  you will  need  to  specify  the  server  path  in  which
it  was  initially hosted  eg  "http://server:2011/Silverlight/silverlight_xap_name.xap"


Tuesday 12 June 2012

How to get sharepoint Current User in Silverlight Client Object Model

sharepoint  current  user can be accessed in silverlight client object model by loading the current user variable to the client context

I  have given an example to  display  the current user  name in  a  textblock.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace User
{
public partial class MainPage : UserControl
{
public MainPage()
{

InitializeComponent();
cc = new ClientContext(ApplicationContext.Current.Url);
cc.Load(cc.Web,s=>s.CurrentUser);    //This is where u load the current use.
cc.ExecuteQueryAsync(new ClientRequestSucceededEventHandler(sucess),null);

}
private void sucess(Object sender, ClientRequestSucceededEventArgs e)
{

Dispatcher.BeginInvoke(data);

}
private void data()
{

textBlock1.Text = cc.Web.CurrentUser.Title;

}
}
}

Retrieving Lookup Value From List Using Sharepoint Client Object Model - Silverlight

you can retrieve  the  lookup  value  in  client  object  model  as  follows

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace lookupvalue
{
public partial class MainPage : UserControl
{
ClientContext cc;

public MainPage()
{

InitializeComponent();
cc = new ClientContext(ApplicationContext.Current.Url);
cc.Load(cc.Web);
listobj = cc.Web.Lists.GetByTitle("your list name");
List s = cc.Web.SiteUserInfoList;
cc.Load(listobj);
CamlQuery cml = new Microsoft.SharePoint.Client.CamlQuery();
view = "<view/>";
cml.ViewXml = view;
_lsititemcoll = listobj.GetItems(cml);
cc.Load(_listitemcoll);
cc.ExecuteQueryAsync(new ClientRequestSucceededEventHandler(OnRequestSucceeded), null);

}
private void OnRequestSucceeded(Object sender, ClientRequestSucceededEventArgs args)
{

// This is not called on the UI thread.
Dispatcher.BeginInvoke(datacon);

}
private void datacon()
{
foreach(ListItem li in _listitemcoll)
{

FieldLookupValue  fvalue  =   li["lookup column  name"]  as FieldLookupValue;
listBox1.Items.Add(fvalue.LookupValue);

}
}
}

How To Access Silverlight function using javascipt - sharepoint

Create  a   silverlight  application  as  follows

using  System;
using  System.Collections.Generic;
using  System.Linq;
using  System.Net;
using  System.Windows;
using  System.Windows.Controls;
using  System.Windows.Documents;
using  System.Windows.Input;
using  System.Windows.Media;
using  System.Windows.Media.Animation;
using  System.Windows.Shapes;

namespace sljsinterop
{
[ScriptableType]
public partial classMainPage : UserControl
{
public MainPage()
{
InitializeComponent();
HtmlPage.RegisterScriptableObject("Page", this);
}
[ScriptableMember]
publicvoid fn(string s)
{
MessageBox.Show(s);
}
}
}
}

The [ScriptableType] attribute  over the class and the [ScriptableMember] over the function provides access for  javascript to invoke  the function.

Now  Build  the  solution and keep  the  .Xap  file  seperately.

First  Create  New Project in  Visual Studio



Then  in  the Project  templates  select   Sharepoint  2010  --->  Empty Project



Select  the  site that  you  want   to deploy  the  web  part  to.



Then  in the  solution explorer  right  click on the project file  and  click add --->New Item

                   



Then in the item template  choose  Sharepoint 2010  ---->   visual webpart template



Now  open  the   design page  of  the  Visual  Webpart




Now  paste   the  xap   file  that  we   created   into   the project  and  include it in the visual  webpart  using  the <Object>  tag.

<objectid="sl1"data="data:application/x-silverlight-2,"type="application/x-silverlight-2"width="600"height ="600">
 <param name="source"value="sljsinterop.xap"/>
 <paramname="onError"value="onSilverlightError"/>
 <paramname="background"value="white"/>
 <paramname="minRuntimeVersion"value="4.0.50826.0"/>
 <paramname="autoUpgrade"value="true"/>
</object>



I have given ID for the object tag as "sl1".Now in Javascript  we are going to create an object of sl1 and use it to call function from silverlight.

The  below  javascript  code  can be present inside the visualwebpart  or  in the page where the webpart is used,you can also use this inside a content editor.

<script language="javascript" type="text/javascript">
function Button1_onclick() {
var sl = document.getElementById("sl1");
sl.focus();
sl.Content.Page.fn("invoked from javascript");
}
 </script>

How to get Sharepoint List User Field Value in Silverlight Client Object Model

you can retrieve the user field value in client object model as follows In the below example,i have retrieved all the values from a user column and populated a list box.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace lookupvalue
{

 public partial class MainPage : UserControl
  {
     ClientContext cc;


     public MainPage()
       {

          InitializeComponent();

          cc = new ClientContext(ApplicationContext.Current.Url);

          cc.Load(cc.Web);

          listobj = cc.Web.Lists.GetByTitle("your list name");

          List s = cc.Web.SiteUserInfoList;
 
          cc.Load(listobj);

          CamlQuery cml = new CamlQuery();

          view = "";

          cml.ViewXml = view;

          _lsititemcoll = listobj.GetItems(cml);

          cc.Load(_listitemcoll);

          cc.ExecuteQueryAsync(new ClientRequestSucceededEventHandler(OnRequestSucceeded), null);

       }


      private void OnRequestSucceeded(Object sender,ClientRequestSucceededEventArgs args)
       {
           Dispatcher.BeginInvoke(datacon);
       }



      private void datacon()
       {

           foreach(ListItem li in _listitemcoll)
           {

             FieldUserValue fvalue = li["User FieldColumn name"] as FieldUserValue;

             listBox1.Items.Add(fvalue.LookupValue);

           }

        }

   } 
}

How to get values From Multiple Values LookUp Field in Silverlight Client Object Model


In the below example  i  have  fetched  values from a multi values Look Up Field  and  populated a  treeview.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace multilookupvalue
{
public partial class MainPage : UserControl
{
ClientContext cc;
string name;
int recordno;
public MainPage()
{

InitializeComponent();
cc = new ClientContext(ApplicationContext.Current.Url);
cc.Load(cc.Web);
listobj = cc.Web.Lists.GetByTitle("your list name");
List s = cc.Web.SiteUserInfoList;
cc.Load(listobj);
CamlQuery cml = new Microsoft.SharePoint.Client.CamlQuery();
view = "<view/>";
cml.ViewXml = view;
_lsititemcoll = listobj.GetItems(cml);
cc.Load(_listitemcoll);
cc.ExecuteQueryAsync(new ClientRequestSucceededEventHandler(OnRequestSucceeded), null);

}
private void OnRequestSucceeded(Object sender, ClientRequestSucceededEventArgs args)
{

// This is not called on the UI thread.
Dispatcher.BeginInvoke(datacon);

}
private void datacon()
{
recordno = 1;
treeview tv1 = new treview();
foreach(ListItem li in _listitemcoll)
{

FieldLookupValue[]  fvalue  =   li["lookup column  name"]  as FieldLookupValue[];
TreeViewItem item = new TreeViewItem();
item.Header = "Record" + recordno;
for(int i=0;i<fvalue.Count();i++)
{

TreeViewItem subitem = new TreeViewItem();
subitem.Header =fvalue[i].LookUpValue;
item.Items.Add(subitem);

}
tv1.Children.Add(item);
LayoutRoot.Children.Add(tv1);
}

}
}