Sunday, September 9, 2012

Difference between 2.0,3.0,3.5,4.0 framework

hi,

Compared to asp.net 2.0 new things added in
Asp.net 3.5
1.listview control.
2.datapager control
3. silverlight
4. linq
5. datalist etc


NET framework 2.0:

It brings a lot of evolution in class of the framework and refactor control including the support of

Generics
Anonymous methods
Partial class
Nullable type
The new API gives a fine grain control on the behavior of the runtime with regards to multithreading, memory allocation, assembly loading and more
Full 64-bit support for both the x64 and the IA64 hardware platforms
New personalization features for ASP.NET, such as support for themes, skins and webparts.
.NET Micro Framework


.NET framework 3.0:

Also called WinFX,includes a new set of managed code APIs that are an integral part of Windows Vista and Windows Server 2008 operating systems and provides

Windows Communication Foundation (WCF), formerly called Indigo; a service-oriented messaging system which allows programs to interoperate locally or remotely similar to web services.
Windows Presentation Foundation (WPF), formerly called Avalon; a new user interface subsystem and API based on XML and vector graphics, which uses 3D computer graphics hardware and Direct3D technologies.
Windows Workflow Foundation (WF) allows for building of task automation and integrated transactions using workflows.
Windows CardSpace, formerly called InfoCard; a software component which securely stores a person's digital identities and provides a unified interface for choosing the identity for a particular transaction, such as logging in to a website


.NET framework 3.5:

It implement Linq evolution in language. So we have the folowing evolution in class:

Linq for SQL, XML, Dataset, Object
Addin system
p2p base class
Active directory
ASP.NET Ajax
Anonymous types with static type inference
Paging support for ADO.NET
ADO.NET synchronization API to synchronize local caches and server side datastores
Asynchronous network I/O API
Support for HTTP pipelining and syndication feeds.
New System.CodeDom namespace.

Wednesday, July 25, 2012

Show Tooltip on Datagridview of relevant record in c#


 private void dgvItemList_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            string newLine = Environment.NewLine;
            string DocNo, Date;
            if (e.ColumnIndex == 1)
            {
                DataGridViewCell cell = dgvItemList.Rows[e.RowIndex].Cells[e.ColumnIndex];
                if (e.Value.Equals("H"))
                {                        
                            string ItemNo = dgvItemList[0, e.RowIndex].Value.ToString();
                            DataTable dtItemNo = App_Code.Class1.TooltipItemList(ItemNo);
                            if (dtItemNo.Rows.Count > 0)
                            {
                                DocNo=dtItemNo.Rows[0]["Invoice No"].ToString();
                                Date = dtItemNo.Rows[0]["Date"].ToString();
                                string Unit = dtItemNo.Rows[0]["Unit Price"].ToString();
                                cell.ToolTipText ="InvoiceNo: "+DocNo+" Date: "+Date+" Price:"+Unit;
                            }    
                        }
                    }
                      
            }

Thursday, July 5, 2012

Open .hta file Application in Windows Form using C#


using System.IO;                 // File.
using System.Diagnostics;        // Process.





 private void button3_Click(object sender, EventArgs e)
 {
    string  sFileHTA = C:\Users\dattatray\Desktop\UPS\RatingToolGenSource\RatingTool.hta";
string sErr = ""; sErr = Open_HTA(sFileHTA); if (sErr != "") { MessageBox.Show(sErr); } } // Open an HTML Application. private string Open_HTA(string sFileName_hta) {  
    string sErr = "";
     if (File.Exists(sFileName_hta) == false)
     {
         return "Application not found.";
     }
     try
     {
         Process p = new Process();
         p.StartInfo.UseShellExecute = true;
         p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
         p.StartInfo.ErrorDialog = true;
         p.StartInfo.FileName = sFileName_hta;
         p.Start();
         p.Dispose();
     }
     catch (Win32Exception ex)
     {
         sErr = ex.Message;
     }
     return sErr;
 }

Friday, June 22, 2012

Passing Parameters to querystring


1. Create new Website
2.Add Gridview on default page
3.Connect sqldatasource connection to it.


<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
            DataSourceID="SqlDataSource1" onrowdatabound="GridView1_RowDataBound">
            <Columns>
                <asp:TemplateField>
                <EditItemTemplate>
               
                </EditItemTemplate>
               
                <ItemTemplate>
               
                    <asp:Label ID="Label1" runat="server"
                        Text='<%# Eval("CustomerID") %>'></asp:Label>
                    <br />
                    <asp:HyperLink ID="HyperLink1" runat="server"
                        Text='<%# Eval("CategoryName") %>'></asp:HyperLink>
               
                </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:LoginConnectionString %>"
            SelectCommand="SELECT [CustomerID], [CategoryName] FROM [Categories]">
        </asp:SqlDataSource>


4.Add this code on Default.aspx.cs



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            HyperLink hl = (HyperLink)e.Row.FindControl("HyperLink1");
            if (hl != null)
            {
                DataRowView drv = (DataRowView)e.Row.DataItem;
                string id = drv["CustomerID"].ToString();
                string companyname = drv["CategoryName"].ToString();
                hl.NavigateUrl = "~/Pages/Order.aspx?customerid=" + id.ToString() + "&Categoryname=" + Server.UrlEncode(companyname.ToString());
            }
        }
    }
}



OutPut:
After Clicking Book


Order.aspx



Thursday, June 21, 2012

Sending an Email using C# .net


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net.Mail;
using System.Net.Mime;


namespace DemoMail
{
    public partial class EmailSender : Form
    {
        String path;
        MailMessage mail = new MailMessage();
        public EmailSender()
        {
            InitializeComponent();
        }

        private void btnSend_Click(object sender, EventArgs e)
        {
            bool show = false;
            SmtpClient SmtpServer = new SmtpClient();
            SmtpServer.Credentials = new  System.Net.NetworkCredential("Your default email","password");
            SmtpServer.Port = 25;
            SmtpServer.Host = "smtp.gmail.com";
            SmtpServer.EnableSsl = true;
            mail = new MailMessage();
            String[] addr = txtMailTo.Text.Split(',');
            try
            {
                mail.From = new MailAddress("from mail ID", "Subject", System.Text.Encoding.UTF8);
                Byte i;
                for (i = 0; i < addr.Length; i++)
                    mail.To.Add(addr[i]);
                mail.Subject = txtSubject.Text;
                mail.Body = txtMessage.Text;
                if (ListBox1.Items.Count != 0)
                {
                    for (i = 0; i < ListBox1.Items.Count; i++)
                        mail.Attachments.Add(new Attachment(ListBox1.Items[i].ToString()));
                }
                //LinkedResource logo = new LinkedResource(path);
                //logo.ContentId = "Logo";
                string htmlview;

                htmlview = txtMessage.Text.Replace("\n", "<br />");
                AlternateView alternateView1 = AlternateView.CreateAlternateViewFromString(htmlview, null, MediaTypeNames.Text.Html);
                // alternateView1.LinkedResources.Add(logo);
                mail.AlternateViews.Add(alternateView1);
                mail.IsBodyHtml = true;

                mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
                mail.ReplyTo = new MailAddress(txtMailTo.Text);
                try
                {
                    SmtpServer.Send(mail);
                    MessageBox.Show("Email Sent", "Email Sender");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }

     
    }
}



Saturday, June 2, 2012

Read Xml File in .net



Public Void GetXmlData()
{
XmlDocument doc = new XmlDocument();
doc.Load("http://www.kirupa.com/net/files/sampleXML.xml");
 
XmlNodeList bookList = doc.GetElementsByTagName("Book");
 
foreach (XmlNode node in bookList)
{

XmlElement bookElement = (XmlElement) node;
 
string title = bookElement.GetElementsByTagName("title")[0].InnerText;
string author = bookElement.GetElementsByTagName("author")[0].InnerText;
string isbn = "";
 
if (bookElement.HasAttributes)
{
isbn = bookElement.Attributes["ISBN"].InnerText;
}
 
Console.WriteLine("{0} ({1}) is written by {2}\n"titleisbnauthor);

}
}

Tuesday, March 20, 2012

Retrive Account Address and Optionset Value of Shipment Term and Payment Term code on sales order form in crm 2011 using odata service


function getContactDetails()
{
    var lookUpObjectValue = Xrm.Page.getAttribute("customerid").getValue();
    if ((lookUpObjectValue != null))
    {
        var lookuptextvalue = lookUpObjectValue[0].name;

        var lookupid = lookUpObjectValue[0].id;
       // alert(lookupid);


    var serverUrl = Xrm.Page.context.getServerUrl();

    //The XRM OData end-point
    var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";


    var odataSetName = "AccountSet";

    var odataSelect = serverUrl + ODATA_ENDPOINT + "/" + odataSetName + "(guid'" + lookupid + "')";

    //alert(odataSelect);

    $.ajax({
        type: "GET",
        contentType: "application/json; charset=utf-8",
        datatype: "json",
        url: odataSelect,
        beforeSend: function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader("Accept", "application/json"); },
        success: function (data, textStatus, XmlHttpRequest) {

            var result_contact= data.d;
         
                        var mc_city1 = result_contact.Address1_City;
                        //replace the fields with the fields on your entity
                        Xrm.Page.getAttribute("shipto_city").setValue(mc_city1);
                        Xrm.Page.getAttribute("shipto_line1").setValue(result_contact.Address1_Line1);
                        Xrm.Page.getAttribute("shipto_line2").setValue(result_contact.Address1_Line2);
                        Xrm.Page.getAttribute("shipto_line3").setValue(result_contact.Address1_Line3);
                        Xrm.Page.getAttribute("shipto_fax").setValue(result_contact.Fax);
                        Xrm.Page.getAttribute("shipto_telephone").setValue(result_contact.Telephone1);
                       Xrm.Page.getAttribute("shipto_name").setValue(result_contact.Address1_PrimaryContactName);
                       Xrm.Page.getAttribute("shipto_stateorprovince").setValue(result_contact.Address1_StateOrProvince);
                        Xrm.Page.getAttribute("shipto_postalcode").setValue(result_contact.Address1_PostalCode);
                        Xrm.Page.getAttribute("shipto_country").setValue(result_contact.Address1_Country);
                       Xrm.Page.getAttribute("shippingmethodcode").setValue(result_contact.Address1_ShippingMethodCode.Value);
                       Xrm.Page.getAttribute("paymenttermscode").setValue(result_contact.PaymentTermsCode.Value);
               //billto addresp

                       Xrm.Page.getAttribute("billto_city").setValue(mc_city1);
                        Xrm.Page.getAttribute("billto_line1").setValue(result_contact.Address1_Line1);
                        Xrm.Page.getAttribute("billto_line2").setValue(result_contact.Address1_Line2);
                        Xrm.Page.getAttribute("billto_line3").setValue(result_contact.Address1_Line3);
                        Xrm.Page.getAttribute("billto_fax").setValue(result_contact.Fax);
                        Xrm.Page.getAttribute("billto_telephone").setValue(result_contact.Telephone1);
                       Xrm.Page.getAttribute("billto_name").setValue(result_contact.Address1_PrimaryContactName);
                       Xrm.Page.getAttribute("billto_stateorprovince").setValue(result_contact.Address1_StateOrProvince);
                        Xrm.Page.getAttribute("billto_postalcode").setValue(result_contact.Address1_PostalCode);
                        Xrm.Page.getAttribute("billto_country").setValue(result_contact.Address1_Country);

                        //Xrm.Page.getAttribute("shipto_line2").setValue(result_contact.Paymenttermscode);


         //paymnt term code


               
        },
        error: function (XmlHttpRequest, textStatus, errorThrown) { alert('OData Select Failed: ' + odataSelect); }
    });

    }

   }