Friday, May 17, 2013

GridView With Scrollbar in Asp.net

 
Gridview have not Scrollbar property so you have to use two things to achieve this

1 Div Tag

<div id="scrollP" style="overflow:scroll;height:100px;
width:200px;">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</div>

2 Panel control

<asp:Panel ID="Panel1" ScrollBars="Both" runat="server" Width="220px">
<asp:GridView ID="GridView1" runat="server"
</asp:GridView>
</asp:Panel>

Check image height & width in pixel during uploading image using File Upload Control.

You can check the size, height and width of image and do some restriction during file upload. Include System.Drawing namespace for this.Here ImageUploader is the File Upload Control.

//********* Chcek Image Size ************
Bitmap img = new Bitmap(ImageUploader.PostedFile.InputStream, false);
int height = img.Height;
// get the height of image in pixel.
int width = img.Width;
// get the width of image in pixel.
int fileSize = (ImageUploader.PostedFile.ContentLength) / 1024;
//get the size of image file.
if (height >= 500 && width >= 500 && fileSize > 500)
{
lblErrorMessage.BackColor = Color.Red;
lblErrorMessage.ForeColor = Color.Black;
lblErrorMessage.Text = "File size not be exceed than 500 KB,500x500 px";
return;
}

//*************** End of Block *****************