.Net & SharePoint '07

Technical blog for .Net and all SharePoint 2007 related Information

About the author

Me(Prince) and my wife are B.E in I.T & C.S.E respectively.  I a certified MCPD: Web from 2007 Dec. I am Intrestes in Web Application, MOSS, EPM, etc.
Now working with Deira International School, as IT Application & Help Manager. I have started my career as "Software Developer" @  REACH Sewn Technologies and Consulting Pvt. Ltd, Bangalore India from Oct 2004 to Feb 2006, then as "Web & Intranet Developer" @ Fosroc International Ltd, Dubai from April 2006 to Sep 2009.
You can catch me on mail@jpy-tech.com or mail@princepy.com. Or on 00971 - 50 - 4284530 

Google Translate

Tag cloud

Calendar

<<  May 2012  >>
MoTuWeThFrSaSu
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

View posts in large calendar

RecentComments

Comment RSS

Google Your Location


My Prefered PDC 2008 topics

PDC 2008


Tags:
Posted by Admin on Tuesday, January 04, 2011 10:34 AM
Permalink | Comments (0) | Post RSSRSS comment feed

Tab control using MultiView and View

Tab control using MultiView and View in asp.net C#

Source : Tab control.aspx (2.38 kb)


Tags: ,
Posted by Admin on Sunday, January 31, 2010 10:33 AM
Permalink | Comments (0) | Post RSSRSS comment feed

ASP.NET Image / Photo Cropper / Resize in C#

thanks to ASP.NET Image / Photo Cropper in C#

You can skip to the demo by clicking here
You can download the source code by clicking here

Sanjay Uttam used javascript obtained from http://www.defusion.org.uk/code/javascript-image-cropper-ui-using-prototype-scriptaculous/

Source : PhotoCropperASP.NetC#.zip (501.17 kb)

XPS Doc: ASP.NET C# - Image Or Photo Cropping.xps (547.48 kb)

protected byte[] CropImageFile(byte[] imageFile, int targetW, int targetH, int targetX, int targetY)
    {
        MemoryStream imgMemoryStream = new MemoryStream();
        System.Drawing.Image imgPhoto = System.Drawing.Image.FromStream(new MemoryStream(imageFile));

        Bitmap bmPhoto = new Bitmap(targetW, targetH, PixelFormat.Format24bppRgb);
        bmPhoto.SetResolution(72, 72);
  
        Graphics grPhoto = Graphics.FromImage(bmPhoto);
        //Adjust settings to make this as high-quality as possible 
        grPhoto.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
        grPhoto.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
        grPhoto.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;

        try
        {
            grPhoto.DrawImage(imgPhoto, new Rectangle(0, 0, targetW, targetH),
                                targetX, targetY, targetW, targetH, GraphicsUnit.Pixel);
            //Only JPG format for this demo
            bmPhoto.Save(imgMemoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);
        }
        catch (Exception e)
         ... //removed code to stay concise
        return imgMemoryStream.GetBuffer();
    }

Tags: , ,
Posted by Admin on Monday, January 18, 2010 10:25 PM
Permalink | Comments (0) | Post RSSRSS comment feed

C# 3.0 - Language Enhancements

Auto Implemented Properties

        // Method 1 - Old Method
        private int orderID;
        public int OrderID
        {
            get { return orderID; }
            set { orderID = value; }
        }
        // Method 2 - C# 3.0 and Above
        public int OrderID{ get; set; }
        // Method 3 - ReadOnly
        public int OrderID{ get; private set; }

Local Type Inference (var keyword)

        // Part 1
        // LocalType Inference(also known as "Implicitly TypedLocal Variables)
        // Emphasis on Local, as in Local Scope, 
        var first = 7;
        Console.WriteLine("First variable is of type: {0}", first.GetType());

        int third = first;
        Console.WriteLine("Third variable is of type: {0}", third.GetType());
        // Part 2
        // At first glance, you might think var is the same as type Object
        // But Not. Why?  Because Object will take the int and box it into an object.
        // var INFERS the actual type ... no boxing.  It is type-safe.
        object second = 7;
        Console.WriteLine("Second variable is of type: {0}", second.GetType());
        // Part 3
        // The type is INFERED and can be used like any other type 
        // from that point on:

        var fourth = "Hello world!";
        Console.WriteLine("Fourth variable is of type: {0}", fourth.GetType());
        var fifth = fourth;
        Console.WriteLine("Fifth variable is of type: {0}", fifth.GetType()); 

Object Collection Initializers

    class Order
    {
        public int OrderID { get; set; }
        public DateTime OrderDate { get; set; }
        public string CustomerName { get; set; }
        public decimal OrderAmount { get; set; }
        public List OrderItems { get; set; }
        public Address BillingAddress { get; set; }
        public Address ShippingAddress { get; set; }


        public Order()
        {
            OrderItems = new List();
        }


        public Order(int orderID, DateTime orderDate)
        {
            OrderItems = new List();

            OrderID = orderID;
            OrderDate = orderDate;

        }

    }
    ....
    ....
    // Standard technique for initializing the new instance of a class
    Order order1 = new Order();
    order1.OrderID = 122;
    order1.OrderDate = DateTime.Parse("12/7/2007 7:08 AM");
    // Using an overloaded constructor as a technique
    // for initializing a new instance of a class.
    Order order2 = new Order(123, DateTime.Parse("12/7/2007 8:08 AM"));
    // NEW C# 3.0 object initialization syntax
    // This syntax IMPLICITLY calls the default constructor
    Order order3 = new Order { OrderID = 124, OrderDate = DateTime.Parse("12/7/2007 8:10 AM"), CustomerName = "Bob", OrderAmount = 395.00M };
    // This syntax EXPLICITLY calls the default constructor
    // Can you spot the difference?
    Order order4 = new Order() { OrderID = 124, OrderDate = DateTime.Parse("12/7/2007 8:10 AM"), CustomerName = "Bob", OrderAmount = 395.00M };
    // NESTED OBJECT INITIALIZERS ... demonstrates containment
    Order order5 = new Order()
    {
        BillingAddress = new Address { Address1 = "123 E Main", City = "Burbank", State = "IL", Zip = "60459" },
        ShippingAddress = new Address { Address1 = "456 Walnut", City = "Richardson", State = "TX", Zip = "75088" }
    };
    // COLLECTION INITIALIZERS
    // Works with any type that implements ICollection
    Order order6 = new Order()
    {
        OrderItems = new List {
            new OrderItem { OrderItemID = 1, ProductName = "Foo", Quantity = 3 },
            new OrderItem { OrderItemID = 2, ProductName = "Bar", Quantity = 2 },
            new OrderItem { OrderItemID = 3, ProductName = "Bazquirk", Quantity = 1 }
        }
    };

Tags:
Categories: ASP.Net 3.5 | c#
Posted by Admin on Thursday, November 26, 2009 7:11 PM
Permalink | Comments (0) | Post RSSRSS comment feed

WSS Field Names for Lists & Document Libraries

Display Name Internal Name GUID Type
For Standard Document Library
ID ID {1d22ea11-1e32-424e-89ab-9fedbadb6ce1} Counter
Content Type ID ContentTypeId {03e45e84-1992-4d42-9116-26f756012634} ContentTypeId
Content Type ContentType {c042a256-787d-4a6f-8a8a-cf6ab767f12d} Text
Created Created {8c06beca-0777-48f7-91c7-6da68bc07b69} DateTime
Created By Author {1df5e554-ec7e-46a6-901d-d85a3881cb18} User
Modified Modified {28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f} DateTime
Modified By Editor {d31655d1-1d5b-4511-95a1-7a09e9b75bf2} User
Has Copy Destinations _HasCopyDestinations {26d0756c-986a-48a7-af35-bf18ab85ff4a} Boolean
Copy Source _CopySource {6b4e226d-3d88-4a36-808d-a129bf52bccf} Text
Approval Status _ModerationStatus {fdc3b2ed-5bf2-4835-a4bc-b885f3396a61} ModStat
Approver Comments _ModerationComments {34ad21eb-75bd-4544-8c73-0e08330291fe} Note
URL Path FileRef {94f89715-e097-4e8b-ba79-ea02aa8b7adb} Lookup
Path FileDirRef {56605df6-8fa1-47e4-a04c-5b384d59609f} Lookup
Modified Last_x0020_Modified {173f76c8-aebd-446a-9bc9-769a2bd2c18f} Lookup
Created Created_x0020_Date {998b5cff-4a35-47a7-92f3-3914aa6aa4a2} Lookup
File Size File_x0020_Size {8fca95c0-9b7d-456f-8dae-b41ee2728b85} Lookup
Item Type FSObjType {30bb605f-5bae-48fe-b4e3-1f81d9772af9} Lookup
Effective Permissions Mask PermMask {ba3c27ee-4791-4867-8821-ff99000bac98} Computed
ID of the User who has the item Checked Out CheckedOutUserId {a7b731a3-1df1-4d74-a5c6-e2efba617ae2} Lookup
Is Checked out to local IsCheckedoutToLocal {cfaabd0f-bdbd-4bc2-b375-1e779e2cad08} Lookup
Checked Out To CheckoutUser {3881510a-4e4a-4ee8-b102-8ee8e2d0dd4b} User
Name FileLeafRef {8553196d-ec8d-4564-9861-3dbe931050c8} File
Unique Id UniqueId {4b7403de-8d94-43e8-9f0f-137a3e298126} Lookup
ProgId ProgId {c5c4b81c-f1d9-4b43-a6a2-090df32ebb68} Lookup
ScopeId ScopeId {dddd2420-b270-4735-93b5-92b713d0944d} Lookup
Virus Status VirusStatus {4a389cb9-54dd-4287-a71a-90ff362028bc} Lookup
Checked Out To CheckedOutTitle {9d4adc35-7cc8-498c-8424-ee5fd541e43a} Lookup
Check In Comment _CheckinComment {58014f77-5463-437b-ab67-eec79532da67} Lookup
Checked Out To LinkCheckedOutTitle {e2a15dfd-6ab8-4aec-91ab-02f6b64045b0} Computed
Document Modified By Modified_x0020_By {822c78e3-1ea9-4943-b449-57863ad33ca9} Text
Document Created By Created_x0020_By {4dd7e525-8d6b-4cb4-9d3e-44ee25f973eb} Text
File Type File_x0020_Type {39360f11-34cf-4356-9945-25c44e68dade} Text
HTML File Type HTML_x0020_File_x0020_Type {0c5e0085-eb30-494b-9cdd-ece1d3c649a2} Text
Source Url _SourceUrl {c63a459d-54ba-4ab7-933a-dcf1c6fadec2} Text
Shared File Index _SharedFileIndex {034998e9-bf1c-4288-bbbd-00eacfc64410} Text
Edit Menu Table Start _EditMenuTableStart {3c6303be-e21f-4366-80d7-d6d0a3b22c7a} Computed
Edit Menu Table End _EditMenuTableEnd {2ea78cef-1bf9-4019-960a-02c41636cb47} Computed
Name LinkFilenameNoMenu {9d30f126-ba48-446b-b8f9-83745f322ebe} Computed
Name LinkFilename {5cc6dc79-3710-4374-b433-61cb4a686c12} Computed
Type DocIcon {081c6e4c-5c14-4f20-b23e-1a71ceb6a67c} Computed
Server Relative URL ServerUrl {105f76ce-724a-4bba-aece-f81f2fce58f5} Computed
Encoded Absolute URL EncodedAbsUrl {7177cfc7-f399-4d4d-905d-37dd51bc90bf} Computed
Name BaseName {7615464b-559e-4302-b8e2-8f440b913101} Computed
File Size FileSizeDisplay {78a07ba4-bda8-4357-9e0f-580d64487583} Computed
Property Bag MetaInfo {687c7f94-686a-42d3-9b67-2782eac4b4f8} Lookup
Level _Level {43bdd51b-3c5b-4e78-90a8-fb2087f71e70} Integer
Is Current Version _IsCurrentVersion {c101c3e7-122d-4d4d-bc34-58e94a38c816} Boolean
Select SelectTitle {b1f7969b-ea65-42e1-8b54-b588292635f2} Computed
Select SelectFilename {5f47e085-2150-41dc-b661-442f3027f552} Computed
Edit Edit {503f1caa-358e-4918-9094-4a2cdc4bc034} Computed
owshiddenversion owshiddenversion {d4e44a66-ee3a-4d02-88c9-4ec5ff3f4cd5} Integer
UI Version _UIVersion {7841bf41-43d0-4434-9f50-a673baef7631} Integer
Version _UIVersionString {dce8262a-3ae9-45aa-aab4-83bd75fb738a} Text
Instance ID InstanceID {50a54da4-1528-4e67-954a-e2d24f1e9efb} Integer
Order Order {ca4addac-796f-4b23-b093-d2a3f65c0774} Number
GUID GUID {ae069f25-3ac2-4256-b9c3-15dbc15da0e0} Guid
Workflow Version WorkflowVersion {f1e020bc-ba26-443f-bf2f-b68715017bbc} Integer
Workflow Instance ID WorkflowInstanceID {de8beacf-5505-47cd-80a6-aa44e7ffe2f4} Guid
Source Version (Converted Document) ParentVersionString {bc1a8efb-0f4c-49f8-a38f-7fe22af3d3e0} Lookup
Source Name (Converted Document) ParentLeafName {774eab3a-855f-4a34-99da-69dc21043bec} Lookup
Title Title {fa564e0f-0c70-4ab9-b863-0177e6ddd247} Text
Template Link TemplateUrl {4b1bf6c6-4f39-45ac-acd5-16fe7a214e5e} Text
Html File Link xd_ProgID {cd1ecb9f-dd4e-4f29-ab9e-e9ff40048d64} Text
Is Signed xd_Signature {fbf29b2d-cae5-49aa-8e0a-29955b540122} Boolean
Merge Combine {e52012a0-51eb-4c0c-8dfb-9b8a0ebedcb6} Computed
Relink RepairDocument {5d36727b-bcb2-47d2-a231-1f0bc63b7439} Computed
       
Standard Custom List Fields
ID ID {1d22ea11-1e32-424e-89ab-9fedbadb6ce1} Counter
Content Type ID ContentTypeId {03e45e84-1992-4d42-9116-26f756012634} ContentTypeId
Content Type ContentType {c042a256-787d-4a6f-8a8a-cf6ab767f12d} Text
Title Title {fa564e0f-0c70-4ab9-b863-0177e6ddd247} Text
Modified Modified {28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f} DateTime
Created Created {8c06beca-0777-48f7-91c7-6da68bc07b69} DateTime
Created By Author {1df5e554-ec7e-46a6-901d-d85a3881cb18} User
Modified By Editor {d31655d1-1d5b-4511-95a1-7a09e9b75bf2} User
Has Copy Destinations _HasCopyDestinations {26d0756c-986a-48a7-af35-bf18ab85ff4a} Boolean
Copy Source _CopySource {6b4e226d-3d88-4a36-808d-a129bf52bccf} Text
owshiddenversion owshiddenversion {d4e44a66-ee3a-4d02-88c9-4ec5ff3f4cd5} Integer
Workflow Version WorkflowVersion {f1e020bc-ba26-443f-bf2f-b68715017bbc} Integer
UI Version _UIVersion {7841bf41-43d0-4434-9f50-a673baef7631} Integer
Version _UIVersionString {dce8262a-3ae9-45aa-aab4-83bd75fb738a} Text
Attachments Attachments {67df98f4-9dec-48ff-a553-29bece9c5bf4} Attachments
Approval Status _ModerationStatus {fdc3b2ed-5bf2-4835-a4bc-b885f3396a61} ModStat
Approver Comments _ModerationComments {34ad21eb-75bd-4544-8c73-0e08330291fe} Note
Edit Edit {503f1caa-358e-4918-9094-4a2cdc4bc034} Computed
Title LinkTitleNoMenu {bc91a437-52e7-49e1-8c4e-4698904b2b6d} Computed
Title LinkTitle {82642ec8-ef9b-478f-acf9-31f7d45fbc31} Computed
Select SelectTitle {b1f7969b-ea65-42e1-8b54-b588292635f2} Computed
Instance ID InstanceID {50a54da4-1528-4e67-954a-e2d24f1e9efb} Integer
Order Order {ca4addac-796f-4b23-b093-d2a3f65c0774} Number
GUID GUID {ae069f25-3ac2-4256-b9c3-15dbc15da0e0} Guid
Workflow Instance ID WorkflowInstanceID {de8beacf-5505-47cd-80a6-aa44e7ffe2f4} Guid
URL Path FileRef {94f89715-e097-4e8b-ba79-ea02aa8b7adb} Lookup
Path FileDirRef {56605df6-8fa1-47e4-a04c-5b384d59609f} Lookup
Modified Last_x0020_Modified {173f76c8-aebd-446a-9bc9-769a2bd2c18f} Lookup
Created Created_x0020_Date {998b5cff-4a35-47a7-92f3-3914aa6aa4a2} Lookup
Item Type FSObjType {30bb605f-5bae-48fe-b4e3-1f81d9772af9} Lookup
Effective Permissions Mask PermMask {ba3c27ee-4791-4867-8821-ff99000bac98} Computed
Name FileLeafRef {8553196d-ec8d-4564-9861-3dbe931050c8} File
Unique Id UniqueId {4b7403de-8d94-43e8-9f0f-137a3e298126} Lookup
ProgId ProgId {c5c4b81c-f1d9-4b43-a6a2-090df32ebb68} Lookup
ScopeId ScopeId {dddd2420-b270-4735-93b5-92b713d0944d} Lookup
File Type File_x0020_Type {39360f11-34cf-4356-9945-25c44e68dade} Text
HTML File Type HTML_x0020_File_x0020_Type {4ef1b78f-fdba-48dc-b8ab-3fa06a0c9804} Computed
Edit Menu Table Start _EditMenuTableStart {3c6303be-e21f-4366-80d7-d6d0a3b22c7a} Computed
Edit Menu Table End _EditMenuTableEnd {2ea78cef-1bf9-4019-960a-02c41636cb47} Computed
Name LinkFilenameNoMenu {9d30f126-ba48-446b-b8f9-83745f322ebe} Computed
Name LinkFilename {5cc6dc79-3710-4374-b433-61cb4a686c12} Computed
Type DocIcon {081c6e4c-5c14-4f20-b23e-1a71ceb6a67c} Computed
Server Relative URL ServerUrl {105f76ce-724a-4bba-aece-f81f2fce58f5} Computed
Encoded Absolute URL EncodedAbsUrl {7177cfc7-f399-4d4d-905d-37dd51bc90bf} Computed
File Name BaseName {7615464b-559e-4302-b8e2-8f440b913101} Computed
Property Bag MetaInfo {687c7f94-686a-42d3-9b67-2782eac4b4f8} Lookup
Level _Level {43bdd51b-3c5b-4e78-90a8-fb2087f71e70} Integer
Is Current Version _IsCurrentVersion {c101c3e7-122d-4d4d-bc34-58e94a38c816} Boolean

Field Tables for Default Lists

The following tables show the names, types, and default property settings for fields used in the default lists for Microsoft® Windows® SharePoint™ Services.

  • Agenda
  • Announcements
  • Attendees
  • Contacts
  • Decisions
  • Document Library
  • Events
  • Form Library
  • Issues
  • General Discussion
  • Links
  • List Template Gallery
  • Meeting Series
  • Objectives
  • Picture Library
  • Site Template Gallery
  • Survey
  • Tasks
  • Things To Bring
  • Web Part Gallery
  • Workspace Pages

Each table displays the default values for the following properties of each field:

  • InternalName — The internal name used for the field.
  • Title — The display name for the field. The values for this property are language-specific.
  • Type — The type of the field.
  • Filterable — Whether the field can be filtered.
  • FromBaseType — Whether the field derives from a base field type.
  • Hidden — Whether the field is displayed in the list.
  • ReadOnlyField — Whether values in the field can be modified.
  • Reorderable — Whether values in the field can be reordered.
  • Required — Whether the field requires values.
  • Sortable — Whether the field can be sorted.

Detailed information about Field Tables for Default Lists is avaliable here


Categories: c# | MOSS | WSS
Posted by admin on Thursday, December 18, 2008 3:04 PM
Permalink | Comments (0) | Post RSSRSS comment feed

SQL 2005 Vs C# : Dynamically generate Class File With Stored Procedure for a Table

When we are writing modules for a big project we might find difficult to write the basic class file with stored procedure for function like Insert, Update, Delete and Select. But Imagine how use full that, you are passing the "TABLE NAME", "CLASS NAME", "NAMESPACE" to a SQL script file, That will Generate the entire class file(in c#) with Stored procedure for that.

Their are some basic rules.

  • Table should HAVE primary kwy which is int, auto increment by 1

I had used some common Columns for all tables link

  • CREATED_BY int
  • CREATED_ON datetime (Default value "GETDATE()")
  • UPDATED_BY int
  • UPDATED_ON datetime (Default value "GETDATE()")
  • ISDELETED bit (Default value "0")
  • STATUS bit (Default valus "1")


Categories: c# | SQL 2005
Posted by admin on Thursday, November 06, 2008 10:41 AM
Permalink | Comments (0) | Post RSSRSS comment feed

How do I send a web page via Email ? / How to read a site page in a string?

private void Page_Load(object sender, System.EventArgs e)
    {
        MailMessage mail = new MailMessage();
        mail.To = "me@mycompany.com";
        mail.From = "you@yourcompany.com";
        mail.Subject = "this is a test email.";
        string url = "http://www.microsoft.com";
        mail.Body = HttpContent(url);
        mail.BodyFormat = MailFormat.Html;
        mail.UrlContentBase = url;
        SmtpMail.SmtpServer = "localhost"//your real server goes here
        SmtpMail.Send(mail);
    }
    //screen scrape a page here
    private string HttpContent(string url)
    {
        WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
        StreamReader sr = new StreamReader(objRequest.GetResponse().GetResponseStream());
        string result = sr.ReadToEnd();
        sr.Close();
        return result;
    }


Categories: ASP.Net 2.0 | c#
Posted by admin on Thursday, October 09, 2008 1:22 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Could not load file or assembly 'System.Web.Extensions' - Error

The "Microsoft.Web.Extensions" is not used anymore. Once you installed AJAX RC1 it will use new dll called "System.Web.Extensions"

It located in C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025\System.Web.Extensions.dll

If you open project with previous AJAX version, you will have to replace old script manager with new one.

To get ASP.NET 2.0 AJAX Extensions, Click Here

Categories: AJAX | ASP.Net 2.0 | c#
Posted by admin on Thursday, September 25, 2008 3:08 PM
Permalink | Comments (1) | Post RSSRSS comment feed

Infopath(VSTA):Populating & Sorting Main DataSource with Datas from Secondary DataSource

Main Data Source:

where SoNFields/SoNField is populating from Secondary Data Source "AGFileEntities" which is sorted according to SortOrder

Secondary Data Source
 

 

public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
    /* ** For  Sorting purpose ** */
    if (!FormState.Contains("InSwap"))
        FormState.Add("InSwap", false);
    /* ** For  Sorting purpose ** */

        XPathNavigator root = this.MainDataSource.CreateNavigator();
        XPathNodeIterator nodes;
        XPathNavigator clone;

        XPathNavigator pListRoot = this.DataSources["AGFileEntities"].CreateNavigator();
        SortList(pListRoot, "SortOrder", "/dfs:myFields/dfs:dataFields/dfs:IPS_Auto_Generated_File_Entities");
        nodes = pListRoot.Select("/dfs:myFields/dfs:dataFields/dfs:IPS_Auto_Generated_File_Entities[@Field_Type='Preliminary SoN']", this.NamespaceManager);
        clone = root.SelectSingleNode("/my:myFields/my:preliminarySoN/my:SoNFields/my:SoNField", this.NamespaceManager).Clone();
        while (nodes.MoveNext())
        {
            clone.SelectSingleNode("my:Title", this.NamespaceManager).SetValue(nodes.Current.GetAttribute("Title", "").Trim());
            clone.SelectSingleNode("my:Description", this.NamespaceManager).SetValue(nodes.Current.GetAttribute("Description", "").Trim());
            root.SelectSingleNode("/my:myFields/my:preliminarySoN/my:SoNFields", this.NamespaceManager).AppendChild(clone);
        }
        root.SelectSingleNode("/my:myFields/my:preliminarySoN/my:SoNFields/my:SoNField", this.NamespaceManager).DeleteSelf();

    }
    else
    {

    }
}

 

 

#region Sorting
private void SortList(XPathNavigator aListRoot, string sortBy, string itemsToSort)
{
    System.Globalization.CultureInfo currentThreadCulture =
        System.Threading.Thread.CurrentThread.CurrentCulture;

    int numPeople = aListRoot.Select(itemsToSort, NamespaceManager).Count;

    /* basic bubble sort implementation */
    for (int i = 1; i < numPeople; i++)  /* xpath is 1-based */
    {
        for (int j = i + 1; j <= numPeople; j++) // keep j ahead of i; we can index [numPeople]
        {
            /* swap (i,j) if i > j */
            string iValue = GetValue(aListRoot, itemsToSort + WrapAsIndexer(i) + "/@" + sortBy);//GetValue(itemsToSort + WrapAsIndexer(i) + "/dfs:" + sortBy);
            string jValue = GetValue(aListRoot, itemsToSort + WrapAsIndexer(j) + "/@" + sortBy);//GetValue(itemsToSort + WrapAsIndexer(j) + "/dfs:" + sortBy);

            /* Do we sort by number or string? */
            /*if (SortAsNumber) */
            /*{ */
            int iNum, jNum;
            if (!Int32.TryParse(iValue, out iNum) || !Int32.TryParse(jValue, out jNum))
            {
                /* Let InfoPath take care of the invalid datatype with its own validation, we'll keep sorting the rest */
                continue;
            }

            if (iNum > jNum)
            {
                Swap(aListRoot, itemsToSort + WrapAsIndexer(i), itemsToSort + WrapAsIndexer(j));
            }
            /*}*/

            /*else // SortAsString */
            /*{ */
            /*    if (String.Compare( */
            /*       iValue, jValue, true */ /*ignoreCase*//*currentThreadCulture) > 0)  */
           /*    { */
            /*        Swap(itemsToSort + WrapAsIndexer(i), itemsToSort + WrapAsIndexer(j)); */
            /*    } */
            /*} */

        } /* end inner-for */
    } /* end outer-for */
}
private string WrapAsIndexer(int intToWrap)
{ return WrapAsIndexer(intToWrap.ToString()); }
private string WrapAsIndexer(string strToWrap)
{ return "[" + strToWrap + "]"; }
private string GetValue(XPathNavigator aListRoot, string xpath)
{ return aListRoot.SelectSingleNode(xpath, NamespaceManager).Value; }
private void SetValue(XPathNavigator aListRoot, string xpath, string value)
{ aListRoot.SelectSingleNode(xpath, NamespaceManager).SetValue(value); }
private void Swap(XPathNavigator aListRoot, string xpath1, string xpath2)
{
    InSwap = true;

    try
    {
        XPathNavigator item1 = aListRoot.SelectSingleNode(xpath1, NamespaceManager);
        XPathNavigator item2 = aListRoot.SelectSingleNode(xpath2, NamespaceManager);

        XPathNavigator item1Clone = item1.Clone();
        item1.ReplaceSelf(item2);
        item2.ReplaceSelf(item1Clone);
    }
    finally /* always undo the reentrancy block at the end */
    {
        InSwap = false;
    }
}
private bool InSwap
{
    get { return (bool)FormState["InSwap"]; }
    set { FormState["InSwap"] = value; }
}
#endregion


Categories: c# | Infopath 2007 | MOSS | VSTOS | WSS
Posted by admin on Tuesday, September 23, 2008 3:04 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Formatting Date and Time Data

Format PatternNameExample
d Short date format 8/27/1989
D Long date format Sunday, August 27, 1989
t Short time format 3:32 PM
T Long time format 3:32:00 PM
f Full date/time format
(short time)
Sunday, August 27, 1989 3:32 PM
f Full date/time format
(long time)
Sunday, August 27, 1989 3:32:00 PM
g General date/time format
(short time)
8/27/1989 3:32 PM
G General date/time format
(long time)
8/27/1989 3:32:00 PM
m or M Month day format August 27
r or R RFC 1123 format Sun, 27 Aug 1989 8:32:00 GMT
s Sortable date/time format 1989-08-27T15:32:00
u Universable sortable date/time format 1989-08-27 15:32:00z
U Universable sortable date/time format Sunday, August 27, 1989 11:32:00 PM
y or Y Year month format August, 1989

Posted by jincy on Wednesday, September 17, 2008 11:09 PM
Permalink | Comments (0) | Post RSSRSS comment feed