Türkçe   |   English
Calendar
Categories
Archive
Links
Blogroll
Files

10.06.2008
Creating thumbnails

In order to generate the thumbnails of the pictures that users have uploaded in our applications, we can use the method below:

public void SaveThumbnail(string path,string thumbnailPath,int newWidth,int newHeight)
        {
            System.Drawing.Image i = System.Drawing.Image.FromFile(path);
            System.Drawing.Image thumbnail = new System.Drawing.Bitmap(newWidth, newHeight);
            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(thumbnail);
            g.DrawImage(i, 0, 0, newWidth, newHeight);
            thumbnail.Save(thumbnailPath, System.Drawing.Imaging.ImageFormat.Jpeg);
        }


Code
Comments(0)

04.05.2008
How to format Business Data Catalog (BDC) List Web Part with Sharepoint Designer

One of the coolest things that comes along with MOSS 2007 is that we can now acquire data via a web service or a database with Business Data Catalog and publish it on Sharepoint portal. Let's say you've created your Application Defition File and you acquired the data over your Business Data List and viewed it on the portal. But you've noticed that unlike the other list web parts, there is no grouping, sorting interface in business data list web part that you can apply these particular operations. At this point, you can edit web part's xsl by clicking the XSL Editor button that you can see in the edit window of the web part. But if you don't want to deal with xsl, Sharepoint Designer comes to your assistance. In order to edit your business data list web part with Sharepoint Designer, open the site that contains the web part from the File menu by clicking Open Site. After that, open the page where the web part is located by double clicking. Select the Business Data List web part that you want to edit. You'll see the > button on the top right corner of the web part. Click it and the menu below will open:



In the menu, click the Dataview Properties link. In the General tab, check the Show toolbar with options for: checkbox and among Filter, Sort, Group actions, check whichever ones you want to apply:



That's it! Thanks to this menu that is opened by clicking the top right corner of the web part, you can not only arrange grouping, filtering etc, but also change things like web part content and table style, paging settings and conditional formatting.

Code
Comments(0)

14.04.2008
Application.Lock() and ApplicationUnLock()

As all of we know, in web applications if we want to keep a global variable that applies to all users and sessions, we can use the ApplicationState. Since ApplicationState can be accessed by more than one thread at the same time, in order to prevent the Application object's value to be set in more than one thread, while setting a value to an Application object, we should call the Lock method of the Application object, set its value and call the UnLock method so that its value is freed for other threads to set:

Application.Lock();
Application["isil"] = "asdasd";
Application.UnLock();

Code
Comments(0)

04.03.2008
Image - RotateFlip

You can call the RotateFlip method of the Image object in order to rotate your images 90, 180 and 270 degrees in your applications. The RotateFlip method takes RotateFlipType enum as parameter. In these enums, you can call the ones with 'Flip' if you want to rotate them on X or Y axises:
 private void Form1_Load(object sender, EventArgs e)
        {
            Image img = Image.FromFile(@"C:\a.jpg");
            img.RotateFlip(RotateFlipType.Rotate90FlipX);
            pictureBox1.Image = img;
        }

 

Code
Comments(0)

25.02.2008
.ashx and null session issue

If session is null while working with ASHX and you can't manage to access session state implement IReadOnlySessionState in your class:

C#

public class Sertifika : IHttpHandler, System.Web.SessionState.IReadOnlySessionState
{
     public void ProcessRequest (HttpContext context)
     {
           context.Response.ContentType = "text/plain";
           context.Response.Write(context.Session["isil"]);
     }


     public bool IsReusable
     {
       get
       {
           return false;
       }
     }
}

VB:

Public Class Sertifika
    Implements System.Web.IHttpHandler
    Implements SessionState.IReadOnlySessionState

    Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

        context.Response.ContentType = "text/plain"
        context.Response.Write(context.Session("isil"))

     End Sub
     ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
        Get
            Return False
        End Get
    End Property

End Class

Code
Comments(3)

Photos

Lighthouse
Show All
Entries
News
Articles