Code Behind:-
SPSite _site;
SPWeb _myWeb;
bool gTemplateExists = false;
string _strList = "ListName";
_site = new SPSite(@"SiteUrl");
_myWeb = _site.OpenWeb();
//check Whether list already exist or not.
if (IsListExists(_myWeb, _strList) == false)
{
CreateNewList(_strList);
}
public bool IsListExists(SPWeb pWeb, string pListName)
{
try
{
SPList list = pWeb.Lists[pListName];
if (list == null)
return false;
else
return true;
}
catch (Exception ex)
{
return false;
}
}
public void CreateNewList(string pListName)
{
try
{
_myWeb.AllowUnsafeUpdates = true;
SPListCollection lists = _myWeb.Lists;
// create new Generic list called ListName
lists.Add("ListName", "List Description", SPListTemplateType.GenericList);
SPList list = _myWeb.Lists["ListName"];
// create Text type new column called "Title"
SPFieldText fldTitle = (SPFieldText)list.Fields.CreateNewField(
SPFieldType.Text.ToString(), " Title ");
fldTitle.Required = false;
// create DateTime type new column called "DateTime"
SPFieldDateTime fldDateTime = (SPFieldDateTime)list.Fields.CreateNewField(
SPFieldType.DateTime.ToString(), "DateTime");
fldDateTime.DisplayFormat = SPDateTimeFieldFormatType.DateTime;
/* add the new fields to the list */
list.Fields.Add(fldTitle);
list.Fields.Add(fldDateTime);
/* finally update list */
list.Update();
/*add the new fields to view */
SPView view = list.DefaultView;
view.ViewFields.Add("Title");
view.ViewFields.Add("DateTime");
view.Update();
_myWeb.AllowUnsafeUpdates = false;
}
catch (Exception ex)
{
}
}
Tuesday, December 14, 2010
DataGrid/ListBox Paging in Silverlight 4
Xaml Code:-
open tag data:datapager name="Datapager1" pagesize="10" displaymode="FirstLastPreviousNext" autoellipsis="True" horizontalalignment="Left" numericbuttoncount="3" istotalitemcountfixed="True/">
Code Behind:
using System.Window.Data;
PagedCollectionView pagedcollectionview = new PagedCollectionView(“Collection”));
Datapager1.Source= pagedcollectionview;
myDatagrid.ItemsSource = pagedcollectionview;
open tag data:datapager name="Datapager1" pagesize="10" displaymode="FirstLastPreviousNext" autoellipsis="True" horizontalalignment="Left" numericbuttoncount="3" istotalitemcountfixed="True/">
Code Behind:
using System.Window.Data;
PagedCollectionView pagedcollectionview = new PagedCollectionView(“Collection”));
Datapager1.Source= pagedcollectionview;
myDatagrid.ItemsSource = pagedcollectionview;
Thursday, December 9, 2010
Modal Window using javascript
To open Modal Dialog Box/Window
Step 1.open script tag
function onClientClick(){
var Options=SP.UI.$Create.Dialogoptions();
Options.Url="url";
Options.Width=500;
Options.Height=200;
SP.UI.ModalDialog.ShowModalDialog(Options);
return false;
}
close script tag
Step 2. To Call javascript function
open anchor(a) tag href="javascript:void(0);" id ="view" onclick="onClientClick"
View All
close anchor tag
Step 1.open script tag
function onClientClick(){
var Options=SP.UI.$Create.Dialogoptions();
Options.Url="url";
Options.Width=500;
Options.Height=200;
SP.UI.ModalDialog.ShowModalDialog(Options);
return false;
}
close script tag
Step 2. To Call javascript function
open anchor(a) tag href="javascript:void(0);" id ="view" onclick="onClientClick"
View All
close anchor tag
GridView
Bind Gridview with Sharepoint list data
Step 1. Create ASPX page, and add following code
asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
asp:GridView
AutoGenerateColumns is false
Step 2. Add reference:- Microsoft.Sharepoint
Step 3.Add following code into ASPX.cs file
Using Microsoft.Sharepoint;
SPSite oSite= new SPSite("SiteUrl");
SPWeb oWeb;
SPList oList;
DataTable dt;
Page_Load()
{
if(!Page.IsPostBack)
{
FetchData();
}
}
Protected void FetchData()
{
oWeb=oSite.OpenWeb();
oList=oWeb.Lists["ListName"];
SPListItemCollection oListCol;
oListCol=oList.Items;
dt=new DataTable ();
dt.Columns.Add("Title",typeof(string));
dt.Columns.Add("Created",typeof(DateTime));
DataRow dr;
foreach(SPListItem oListItem in oListCol)
{
dr=dt.Rows.Add();
dr["Title"]=oListItem["Title"].tostring();
}
gridview1.Datasource=dt;
gridview1.DataBind();
}
Step 1. Create ASPX page, and add following code
asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
asp:GridView
AutoGenerateColumns is false
Step 3.Add following code into ASPX.cs file
Using Microsoft.Sharepoint;
SPSite oSite= new SPSite("SiteUrl");
SPWeb oWeb;
SPList oList;
DataTable dt;
Page_Load()
{
if(!Page.IsPostBack)
{
FetchData();
}
}
Protected void FetchData()
{
oWeb=oSite.OpenWeb();
oList=oWeb.Lists["ListName"];
SPListItemCollection oListCol;
oListCol=oList.Items;
dt=new DataTable ();
dt.Columns.Add("Title",typeof(string));
dt.Columns.Add("Created",typeof(DateTime));
DataRow dr;
foreach(SPListItem oListItem in oListCol)
{
dr=dt.Rows.Add();
dr["Title"]=oListItem["Title"].tostring();
}
gridview1.Datasource=dt;
gridview1.DataBind();
}
Silverlight Basic
What is Silverlight?
1. Silverlight is a development platform for creating rich interactive application and business applications for web, desktop and mobile devices.
2. Silverlight is a free plug-in compatible across multiple browsers, devices and OS.
3. Silverlight uses XAML.
4. To create Silverlight content/Application, we can use existing tools like Visual Stdio or dedicated tool like ExpressionBlend.
5.Silverlight technology is developed by Microsoft which incorporates the same functionality as Adobe Flash.
6. Silverlight can be connected to data, servers and services.
What is difference between WPF and Silverlight?
Silverlight is a browser plugin for running it on web application while WPF is used for window application.
What are different layout controls available in Silverlight?
There are basically three controls
1.Canvas :-It arranges child elements according to X,Y coordinate.
2.Grid :-It arranges child elements either in rows or columns.
3. Stack Panel :-It arranges child elements in horizontal or vertical manner.
What kind of audio video formats are supported in Silverlight?
Silverlight supports windows Media Audio and Video(WMA, WMV7-9) as well as MP3 audio.
1. Silverlight is a development platform for creating rich interactive application and business applications for web, desktop and mobile devices.
2. Silverlight is a free plug-in compatible across multiple browsers, devices and OS.
3. Silverlight uses XAML.
4. To create Silverlight content/Application, we can use existing tools like Visual Stdio or dedicated tool like ExpressionBlend.
5.Silverlight technology is developed by Microsoft which incorporates the same functionality as Adobe Flash.
6. Silverlight can be connected to data, servers and services.
What is difference between WPF and Silverlight?
Silverlight is a browser plugin for running it on web application while WPF is used for window application.
What are different layout controls available in Silverlight?
There are basically three controls
1.Canvas :-It arranges child elements according to X,Y coordinate.
2.Grid :-It arranges child elements either in rows or columns.
3. Stack Panel :-It arranges child elements in horizontal or vertical manner.
What kind of audio video formats are supported in Silverlight?
Silverlight supports windows Media Audio and Video(WMA, WMV7-9) as well as MP3 audio.
Subscribe to:
Posts (Atom)