Thursday, September 25, 2008

Baanke Bihari

ISKCON-MATHURA

Vaishno Devi





Jai mata Di..!!

12 Jyotirlingas



Meaning:

Lord Somnath is in the country Saurashtra, Mallikarjuna is on the Shree Shailam,

Mahakala is in Ujjayani, Parameshwar belongs to Onkar,

Kedar in the mountain of Himalaya, Bhimashankar is in the country of Dakini,Viswesh belongs to Varanasi, the Lord Trayam bakam resides on the shore of Gautami river,

Baidyanath lies on the land of ashes and the Lord of snake lives in the wooden forest.

Lord Rama stays near the sea where it was bridged by him and Lord of Ghushma resides in the abode of Shiva.

If one recites the twelve names in the early morning,

he will get rid of all sins and will get all fruits of his efforts.






GRINESHWAR







KEDARNATH





TRYAMBAKESHWAR





VISHVESHAM 


NAGESHWAR




RAMESHWARAM




Bhimashankara



Baijnath (Vaidyanatha)



Omkareshwar 


Mahakalam



MallikaArjunam






Somnath


Change Image Attributes dynamically

This Snippet changes the Image details like : Author,Title,Summary,Comments etc ..when you draw image from System.Drawing namespace::

Also it causes a Force download and you can enetr your own file attributes in Author,Title,Summary,Comments etc ..


When you visit the any Page and save Image:
Below code will Save the User Name , the Ip Address ,time and the name of the image with force downlaod.
This string can be added in any Attribute :  Author,Title,Summary,Comments etc ..
Remember to FInd the User Yourself by MemberShip API

Clicking on any the Image button,or Datagrid,Gridview,Listview having Image Button:
pass the Query string to next page :

                          asp:ImageButton ID="imgButton" runat="server" 
                         ImageUrl='%# Eval("imageid", "Gallery/Thumbnail/{0}.jpg") %' OnClick="imgButton_Click" 
                            


 protected void imgButton_Click(object sender, ImageClickEventArgs e)
    {

        ImageButton img = (ImageButton)sender;
        HiddenField HF = (HiddenField)Page.Master.FindControl("HiddenField1");

        HF.Value = img.ImageUrl.ToString();

        Response.Redirect("openImage.aspx?ID=" + HF.Value + "");

    }

//and on second page Page load event :

protected void Page_Load(object sender, EventArgs e)
    {

        string Img = Request.QueryString["ID"].ToString();
        System.Web.UI.WebControls.Image im = new System.Web.UI.WebControls.Image();

        string strUrl = Img.Split('/')[2].ToString();
        string newImgUrl = strUrl.Replace(strUrl, "Gallery/HiRes/" + strUrl);
        im.ImageUrl = newImgUrl;
        im.AlternateText = Img;


        MembershipUser Usr = Membership.GetUser();
            
        string strIpAddress = Request.UserHostAddress;

        string strImageName = im.ImageUrl;
        DateTime Time = DateTime.Now.ToLocalTime();
        string strDestFileName = Usr + " - "+ strIpAddress + " - " + Time + " - " + System.IO.Path.GetFileName(strImageName);
        WriteProperties(strDestFileName , strImageName);
        
        Form.Controls.Add(im);
        
    }

 private void WriteProperties(string text ,string ImageName)
    {
        
        System.Drawing.Image imImage = System.Drawing.Image.FromFile(Server.MapPath("~/") + ImageName);
        System.Drawing.Imaging.PropertyItem[] AllProperties = imImage.PropertyItems;
        System.Drawing.Imaging.PropertyItem NewProp = AllProperties[0];


        byte[] Value = System.Text.ASCIIEncoding.Unicode.GetBytes(text);
        NewProp.Id = 40092;  // Comments
        NewProp.Len = Value.Length;
        NewProp.Value = Value;
        NewProp.Type = 1;
        imImage.SetPropertyItem(NewProp);
        ShowImage(imImage);
                      
    }

 private void ShowImage(System.Drawing.Image bmp)
    {
         HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.ContentType = "image/jpeg";
        HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=");
        bmp.Save(HttpContext.Current.Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg);

        bmp.Dispose();
        HttpContext.Current.Response.End();
    }

Thanks,
Nitin Sharma


Tuesday, September 16, 2008

Delegates Demystified

Delegates are function pointers in C# that are managed and type safe and can refer to one or more methods that have identical signatures. Delegates in C# are reference types. They are type safe, managed function pointers in C# that can be used to invoke a method that the delegate refers to. The signature of the delegate should be the same as the signature of the method to which it refers. According to MSDN, "A delegate in C# is similar to a function pointer in C or C++. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked. Unlike function pointers in C or C++, delegates are object-oriented, type-safe, and secure."
C# provides support for Delegates through the class called Delegate in the System namespace. Delegates are of two types.
· Single-cast delegates
· Multi-cast delegates
A Single-cast delegate is one that can refer to a single method whereas a Multi-cast delegate can refer to and eventually fire off multiple methods that have the same signature.
The signature of a delegate type comprises are the following.
· The name of the delegate
· The arguments that the delegate would accept as parameters
· The return type of the delegate
A delegate is either public or internal if no specifier is included in its signature. Further, you should instantiate a delegate prior to using the same.

Single Cast Delegate:

class MPS
{
delegate void MPSDel();
delegate void MPSCallDel (int i);
public void fun()
{
MPSDel d1 = new MPSDel(MPS);
d1();
MPSCallDel d2 = new MPSCallDel (HMC);
d2 ( 5 ) ;
}
public void MPS()
{
Response.Write(“WelCome to MPS”) ;
}
public void HMC(int i)
{
Response.Write(i) ;
}
}



Multicast Delegate:


delegate void del3(int i);

public void function2(int i)
{
Response.Write(i);
Response.Write("
");
}
public void function3(int s)
{
s = 900;
Response.Write(s);
Response.Write("
");
}





protected void Button1_Click(object sender, EventArgs e)
{
del3 d3 = new del3(function2);
d3 += new del3(function3);
d3(10);
}



Output:

10
900