Monday, May 23, 2011

Inheritance


When we are calling the object of child class. always constructor of base class calls the first

In desctructor it is always first desctuct the child object than parent

A a2 = new B();      allowed

but we can not give reference of parent to child.


as int are structs and cannot have reference to object
int is using IEquatable interface to implement
which contains Equals method through which int can chek equality comparison there.

***************************************
namespace Test2
{
 public class A
 {
  public A()
  {
   Console.WriteLine("This class A");
  }
 }
 
 public class B : A 
 {
  public B()
  {
   Console.WriteLine("This class B");
  }
 }
 
 
 public class C : B
 {
  public C()
  {
   Console.WriteLine("This class C");
  }
 }
}




namespace Test2
{
 class Program
 {
  static void Main(string[] args)
  {
   A a = new A();
   System.Console.Read();
   B b = new B();
   System.Console.Read();
   C cC1 = new C();
   System.Console.Read();
  }
 }
}

File Upload Control in asp.net is not working with the update panel

Hi All

We are facing the problem of file upload control with the update panel
To solve this we need to do following thngs


<form id="form1" runat="server">
    <asp:FileUpload ID="FileUpload1" runat="server" />
    <asp:UpdatePanel ID="Updatepanel1" runat="server">
        <Triggers>
            <asp:PostBackTrigger ControlID="Button1" />
        </Triggers>
        <ContentTemplate>
            
            <p>
                <asp:Button ID="Button1" runat="server" Text="Upload" OnClick="Button1_Click" /></p>
            <p>
                <asp:Label ID="Label1" runat="server"></asp:Label></p>
        </ContentTemplate>
    </asp:UpdatePanel>
    </form>


It is working with below texts

Page.Form.Attributes.Add("enctype", "multipart/form-data");

asynch file upload

<ajaxToolkit:AsyncFileUpload OnClientUploadError="uploadError"     OnClientUploadComplete="uploadComplete" runat="server"     ID="AsyncFileUpload1" Width="400px" UploaderStyle="Modern"     UploadingBackColor="#CCFFFF" />

Wednesday, April 20, 2011

OO design principles

Forcefully download the pdf files

Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition""attachment; filename=axz.pdf");
string path = "xyz.pdf";
byte[] buffer = System.IO.File.ReadAllBytes(path);
Response.OutputStream.Write(buffer, 0, buffer.Length);
Response.Flush();

Monday, April 11, 2011

Tuesday, March 29, 2011

Left outer join in Linq C#


Left join Linq

from a in aa
join a in xx on a.d equals x.y into DefaultOrEmptyXDetails
from a in DefaultOrEmptyXDetails.DefaultIfEmpty()
select new a)