Posts

Showing posts from August, 2012

programatically highlight words using c#:

Image
programatically highlight words using c#:         Your output like this.... xaml:     create a text block with name of tb.  < TextBlock Height =" auto " TextWrapping =" Wrap "  Width =" 200 " HorizontalAlignment =" Left " Margin ="45,12,0,0" Name =" tb " Text =" Textblock "  VerticalAlignment =" Top " /> c# code:          string source = " This is a example of Highlight a word using c# ";   //Your source         string [] highlight_words = { " example ", " word " };                          //Your Key word On your button click event call this function like this          private void button1_Click( object sender, RoutedEventArgs e)           {             highilight(source);            } And copy paster this Function:      public void highilight( string source)         {             int min = 0, chk = 0, chk2 = 0, tmp = 0;             string negw

Silverlight Chart: Displaying Data Above the Column

Image
Columnseries bar value in top of the column in silverlight chart:    Your final output will come like this XAML code:    Add the following xaml code in your chart < toolkit:Chart Canvas.Top= " 80 " Canvas.Left= " 10 " x:Name= " chartname " Margin= " 88,68,312,114 ">                       < toolkit:Chart.Series >                 < toolkit:ColumnSeries Title= " week1 " IndependentValueBinding= "{Binding Path = Value }" DependentValueBinding= "{Binding Path = Key }">                     <toolkit:ColumnSeries.DataPointStyle>                         <Style TargetType="toolkit:DataPoint">                            <Setter Property="Template">                             <Setter.Value>                                 <ControlTemplate TargetType="toolkit:ColumnDataPoint">                                     <Grid Background

change column/bar/area series datapoint's color of columnseries chart in silverlight

Image
change column/bar/area series datapoint's color  in silverlight:   Your Final output will be like this. Xaml Code:      Add the Following Code in your xaml < toolkit:Chart Canvas.Top =" 80 " Canvas.Left =" 10 " x:Name= " chart _ name " Margin= "88,68,312,114">                       < toolkit:Chart.Series >                 < toolkit:ColumnSeries Title= " week1 " IndependentValueBinding= "{Binding Path = Value }" DependentValueBinding= "{Binding Path = Key }">                     < toolkit:ColumnSeries.DataPointStyle >                         < Style TargetType= " t o olkit:DataPoint" >                             < Setter Property= "Background" Value =" Red "/>                         </ Style >                     </ toolkit:ColumnSeries.DataPointStyle >                 </ toolkit:ColumnSeries >                  < t

Silverlight Chart Example

Image
Silverlight Chart Example :                           In this example i explained  how to create a Column series chart in silverilght. I directly go to the coding part.In this example i added 3 column series inside the chart.If you want to single column series you can just add one column series inside the chart. OutPut Screen  :   Xaml Code : Paste the following code between user control  < Grid x:Name =" LayoutRoot " Background=" White ">         < toolkit:Chart HorizontalAlignment ="Left" Margin ="12,12,0,0" Name=" chart1 " Title ="Chart Title" VerticalAlignment="Top" Height="266" Width="365">             < toolkit:ColumnSeries DependentValuePath ="X" IndependentValuePath ="Y" ItemsSource ="{ Binding }" DependentValueBinding ="{Binding Value1}" IndependentValueBinding=" {Binding Name }"/>             < tool

display minimum and maximum values for LinearAxis in Silverlight Toolkit's columnseries

Image
minimum/maximum values & showgridline propertie s in silverlight chart axis:      Add the following XAML code,above the last line of your chart. see the following image code:   < toolkit:Chart.Axes >        < toolkit:LinearAxis Orientation= "Y" Minimum= " 0 " Maximum= " 100 "  Height= " auto"/>       </ toolkit:Chart.Axes > You can set intervels & show or hide gridlines also:     For example in that same code you can add intervel property. example   < toolkit:Chart.Axes >        < toolkit:LinearAxis Orientation= "Y" ShowGridLines =" False " Minimum= " 0 " Maximum= " 100 " Interval =" 20 "  Height= " auto"/>       </ toolkit:Chart.Axes >  Output:  

count number of occurrences in string c#

count number of occurrences in string c#   First use the following namesapce           using System.Text.RegularExpressions;    Use the following Regx code to count             string source= "one two three one two one"            int count = Regex.Matches(source, "\\b(" + Yourstring + ")\\b" ).Count;   that "\\b(" is used for eliminate specal charcter.

how to get string between two strings in c#

how to get string between two strings in c# Example:     string source= "one two three four five"    If you want to get strins between "one" and "five" then use this function call    string temp = GetStringBetween( "one " , "five" , source); And the copy the following function & paste in your program.   public static string GetStringBetween( string strbegin, string strend, string source)         {             int iIndexOfBegin = source.IndexOf(strbegin) + strbegin.Length;             string s1 = source.Substring(iIndexOfBegin);             int iIndexOFfEnd = s1.IndexOf(strend);             string s2 = s1.Substring(0, iIndexOFfEnd);             return s2;         } Output: "two three four"

How to call a page in silverlight:

How to call a page in silverlight:      In silverlight you can use the following code to call a page with in silverlight project.         void buttion_Click( object sender, RoutedEventArgs e)         {             this .Content = new MainPage ();      //here MainPage is page name         }

How to remove legend from silverlight chart:

Image
How to remove legend from silverlight chart: Step-1:     Copy the following code, and past it second line of your chart xml code.(see the following image)                 < toolkit:Chart.LegendStyle >             < Style TargetType = "toolkit:Legend">                 < Setter Property = "Width" Value = "0" / >                 < Setter Property = "Height" Value = "0 " />               </ Style >          </ toolkit:Chart.LegendStyle >

how to add audience in sharepoint

Image
How to Add target audience for a web part in SharePoint : Note:                     You Canot add audience directly to the web part or top navigation links. You can only add the user groups in that audience field(It will take audience from that group) Check The Following:         1. Activate the "Sharepoint Server Publishing Infrastructure" (site actions->site settions->site collection adminstration->sitecollection features->Sharepoint Server Publishing Infrastructure(Activate this))       2.check if  "Enable audience targeting" is selected in(site actions->site settions->site collection adminstration->Site collection navigation(check here)) Step-1:    Create some sharepoint user groups, or you can use existing groups.Now go to the web part(edit webpart->advanced settings->Audience)  And do the following.  (you can also add audience for top navigationn bar as same way).    Step-2:                Se

JavaScript in Quick Launch and Top Link Bar in sharepoint 2010:

Image
JavaScript in Quick Launch and Top Link Bar in sharepoint 2010: You can add javascript functions in you quick launch and top navigation bar.(for creating some alert messages) Step-1:       go to siteactions->site settings->Lookand Feel->Quick Launch bar->New Navigation link-> (There add the java script function in new link... ex- JavaScript:alert('Hello world!') ) See the below image.  Step-2:     Click ok, and go to home page and  click on newly created quick launch link.Your alert message will appear. Error:      If sharepoint publishing infrastructer is activated in your site then it will show error like follow How to check that->(Go to Site Actions-> Site Settings->Look and Feel-> and see if you have “Quick Launch” or “Navigation”.  “Navigation” is for publishing sites) If you Have Navigation then it wont work. How to Deactivate that Publishing Feature:            Site Actions->Site Settings->Site collecti

how to convert a string into datetime in c#

How to convert a string into datetime in c# step-1:    First include this namespace    using System.Globalization; Step-2:     Use the following code. DateTime datetime = DateTime .ParseExact( "01-may-1990" , "dd-MMMM-yyyy" , CultureInfo .InvariantCulture, DateTimeStyles .None);            

how to get month number from month name in c#

how to get month number from month name in c#: step-1:     inclued this name space using System.Globalization; step-2:     use this code string no= Convert . ToString ( DateTime .ParseExact( "may" , "MMMM" , CultureInfo .InvariantCulture).Month) Here instead of "may" you can give your month name.

how to get month name from month number in c#

how to get month name from month number in c# : step-1:    use this name space    using System.Globalization; step-2:   use the bleow code   string month= CultureInfo .CurrentCulture.DateTimeFormat.GetMonthName(1) Here 1 is for january month.You can give numbers(1 to 12) as per your need.

how to change datagridview header color using blender

Image
How to change datagridview header color using blender:    Here we will see how to change datagrid header background color using blender. Step-1:     Open your project  with expression blend, and double click on your page.  step-2:      Right click on your datagrid->Edit addtional template->edit column header style->edit a copy(if u create first time then you have to give edit a copy)  Step-3:     Give apply to all(if you apply all column header and all data grids)->click ok  Step-4:     Right click on BackgroundGradient->and right side properties change the color(see below image) Step-5:    After changing the background color, If you want to change foreground color then, right click on data grid, and click view xml Step-6:    Inthat xml page scroll up for few lines, and there you will see the foreground option, there you can change the color Step-7:     Finally you have done it.

how to add Quick Launchbar in sharepoint Programatically

  how to add  Quick Launchbar in sharepoint Programatically: step1:   First you need to add the following name space using Microsoft.SharePoint; using Microsoft.SharePoint.Navigation; using Microsoft.SharePoint.WebControls; using Microsoft.SharePoint.Publishing; step 2: And next include the following code in your program   protected void Page_Load(object sender, EventArgs e)         {             using ( var site = new SPSite ( SPContext .Current.Site.Url))             {                 var rootPubweb = PublishingWeb .GetPublishingWeb(site.RootWeb);                 var subwebs = rootPubweb.GetPublishingWebs();                 site. RootWeb .AllowUnsafeUpdates = true ;                 string [] headnode = { "link1 ", "link2" };                 SPNavigationNodeCollection nodes =  site.RootWeb.Navigation.QuickLaunch;                 for (int j = 0; j < headnode.Length; j++)                 {                     SPNavigationNode na

how to add Top navigaiton bar link in sharepoint Programatically

how to add  Top Navigation link in sharepoint  Programatically: step 1: First you need to add the following name space using Microsoft.SharePoint; using Microsoft.SharePoint.Navigation; using Microsoft.SharePoint.WebControls; using Microsoft.SharePoint.Publishing; step 2: And next include the following code in your program   protected void Page_Load(object sender, EventArgs e)         {             using ( var site = new SPSite ( SPContext .Current.Site.Url))             {                 var rootPubweb = PublishingWeb .GetPublishingWeb(site.RootWeb);                 var subwebs = rootPubweb.GetPublishingWebs();                 site. RootWeb .AllowUnsafeUpdates = true ;                 string [] headnode = { "link1 ", "link2" };                 SPNavigationNodeCollection nodes_t = site. RootWeb .Navigation.TopNavigationBar;                 for (int j = 0; j < headnode.Length; j++)                 {                     SPNavigat

how to retrieve data from active directory using c#

how to retrieve data from active directory using c#: step 1: First include this namespace  using System.DirectoryServices; step 2: And in page load function use the following code (Use your active directory domain name,username,password in the following code)   protected void Page_Load(object sender, EventArgs e)         {             string domainname = "mydomain" ; string username = "admin" ; string password = "1234" ;             DirectoryEntry entry = new DirectoryEntry ( "LDAP://" + domainname, username, password,    AuthenticationTypes .Secure);             DirectorySearcher search = new DirectorySearcher (entry);             search.Filter = "(SAMAccountName=" + username + ")" ; //This is your login name(it filter based on                                                                                                                             //your login user name)             SearchResult res

sharepoint get current user login name using c# (Server Object Model) :

sharepoint get current user login name using c# ( Server Object Model) :       You Can get the current logged in user name usin the following code                       string name = SPContext .Current.Web.CurrentUser.LoginName;         (before that you have to use this namespace  using Microsoft.SharePoint;) To get current user in client object model  see this link

how to get all users in sharepoint group using silverlight

how to get all users in sharepoint group using silverlight : use following code to Retrive All shareopint fielduser valus C# code: 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 Microsoft.SharePoint.Client; using Microsoft.SharePoint; namespace users { public partial class MainPage : UserControl { string user; GroupCollection G roupcoll; ClientContext site;   public  MainPage() { InitializeComponent(); site = new ClientContext ( ApplicationContext .Current.Url); site.Load(site.Web); G roupcoll = site.Web.SiteGroups; site.Load(G roupcoll , groups => groups.Include(group => group.Users)); site.ExecuteQueryAsync( new ClientRequestSucceededEventHandler (OnRequestSucceeded),

How to retrieve multiple lookup values from sharepoint using silverlight

How to retrieve multiple lookup values from sharepoint using silverlight : In the below example  i  have  get 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 qry= new CamlQuery(); qry .ViewXml =   "<view/>"; _lsititemcoll = listobj.GetItems( qry ); c