Friday, September 25, 2009

Get image height and width without creating bitmap

By HAFIZ Kashkoush

Usually to resize an image we upload the image ,create bitmap ,resize it
and save the new resized image.
I can use this technique in case that I need a new resized image file otherwise
this technique become very complicated .

In this article I going to
1:-Upload an image to Image control (image1)
2:-Get image info (width and height)
3:-When user click resize button the image will be resized for 50%
of it original size.

First i add to my form 2 controls
A:-Image control -Image ID="Image1"
B:-Button control to resize image - Button ID="BResize"

2:- In my code I declare 3 global variables
Dim ImageWidth As Integer 'Image width
Dim ImageHeight As Integer 'Image height
Dim imageurl As String 'Image URL

3:- In my page load event I load the image to image1 control and get image info.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
'************************************************************************
'******* This string contain image URL
'******* My image name is "1_o.jpg" and it located in my application
'******* directory in this case the image URL="1_o.jpg"

'************************************************************************
imageurl = Server.MapPath("1_o.jpg")
'******** Load the image into image1 control
Image1.ImageUrl = imageurl
'******** Get Image Info
Dim fullSizeImg As System.Drawing.Image = System.Drawing.Image.FromFile(imageurl)
'******** Image Width
ImageWidth = fullSizeImg.Width
'******** Image Height
ImageHeight = fullSizeImg.Height
End Sub

4:-In the button resize click event I resize the image to 50% of it original size
by changing image1 width an height values.
Protected Sub BResize_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Image1.Height = Int(ImageHeight / 2)
Image1.Width = Int(ImageWidth / 2)
End Sub

Thursday, September 17, 2009

Very Compatible DHTML Menu ASP.NET User Control

Introduction
A DHTML menu is something many web developers use these days as those provide a friendly and hierarchical interface for users. In a project I�m working on, I need one of those, and I searched the web to find an ASP.NET control. There are some good examples of menu controls but none of them gives what really I want (cross-browser, VB.NET, code available, free, and with possibilities for nice styles). Then I found Sylvain Machefert�s work (in French). He is a web developer with good CSS, JavaScript and cross browser issues knowledge, who made a very compatible DHTML menu and released it to public. The menu even works on text based browsers, reading technologies for visually impaired considered, and the menu is not visible when printing your page. Also, it can be customized in many ways and it supports icon images.

Read this article

Thursday, September 3, 2009

AJAX - Databinding to an Accordion

The Accordion control in the AJAX Control Toolkit provides multiple panes and allows the user to display one of them at a time. Panels are usually declared within the page itself, but binding to a data source offers more flexibility.

Read this article