News

Loading...

Search This Blog

Loading...

Tuesday, November 27, 2012

Find Height and Width of image using C#

I know, there are some requirements in which we need to find out the image's height and width.
Either the image is on server or it's been uploaded using fileupload control in asp.net using C#.

Following is the example for finding the height and width of image which is being uploaded through FileUpload Control in asp.net.
My favourite language is C#, so this code is also written in C#.
Those who love VB, please use a code convertor.

lets say fileUpload control as fiUpload

protected void findHieghtWidht_Click(object sender, EventArgs e)
{
    string uploadImageType = fiUpload.PostedFile.ContentType.ToString().ToLower();
    stirng uploadImageName = fiUpload.PostedFile.FileName;
    System.Drawing.Image uploadImage = System.Drawing.Image.FromStream(fiUpload.PostedFile.InputStream);
    float imageWidth = uploadImage.PhysicalDimension.Width;
    float imageHeight = uploadImage.PhysicalDimension.Height;


 Same way you can load the image stored on server, and get the height and width.

344808_CrashPlan 10% Savings - 120x600 animated

Thursday, December 22, 2011

Failed To Load Viewstate

Once I encountered the following error

Failed to load viewstate.

The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.

For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request


I searched a lot on google and finally i found one solution.

Here is the reason why the error happens:

If a control is added dynamically to a placeholder say (UserControl1.ascx) and the control's viewstate is enabled ,thenafter on the next postback a different control is added say (UserControl2.ascx) to the placeholder.

when asp.net try to load the viewstate of the control contained at the placeholder it's expecting the previous control  u added :(UserControl1.ascx) but it will encounter another control instead  (UserControl2.ascx) in the place of the first control SO IT WILL FAIL.

Viewstate of the control tree in the placeholder child controls is saved by index not by key so even if we give our ascx control as a key before adding it to the placeholder we will get the same error.


Solution:

Just disable viewstate of the usercontrol.


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind=" abc.aspx.cs" Inherits="#####"  EnableViewState="false"%>

20% OFF + FREE Set-up on select items! Online Exclusive for New Customers Only.

Saturday, October 1, 2011

Maintain tabs in SpryTabbedPanels

This post helps you to maintain the tab index of spry tabpanal at every post back event

I have done small changes in SpryTabbedPanels.js for this post back purpose

You can download the upgraded version of SpryTabbedPanels.js at


To use this script follow the steps

Steps to be followed to implement spreyTabbedpanels

Save on Snacks and Party Favorite Foods

Friday, February 11, 2011

Delete file which is already in use using C#.net

Sometime scenario arises where we need to delete a file using C#.
But sometime an error is thrown like "File is already in use. Not able to delete"

Here is the solution to delete that file

if(File.Exists(FullFileName))
{
       GC.Collect();
       GC.WaitForPendingFinalizers();
       FileInfo f = new FileInfo(FullFileName);
       f.Delete();
}

Wednesday, January 5, 2011

Days gap between two dates in ORACLE

To find out days gap between two dates excluding business holidays in oracle use following query.

SELECT count(dt) FROM
(SELECT TO_DATE(StartDate) + level - 1 dt FROM dual CONNECT BY level <=(TO_DATE(EndDate)-TO_DATE(StartDate)))
where to_char (dt,'D')<>1

Below written query is the example of it.

This query returns days count between 30-nov-2010 and 12-dec-2010 excluding Sundays
(1 for sunday,2 for monday and so on......)

SELECT count(dt) FROM
(SELECT TO_DATE('30-nov-2010') + level - 1 dt FROM dual CONNECT BY level <=(TO_DATE('12-Dec-2010')-TO_DATE('30-nov-2010')))
where to_char (dt,'D')<>1 

To find out dates between two dates use following query

SELECT to_char(dt,'dd/MM/yyyy') as date FROM
(SELECT TO_DATE(StartDate) + level - 1 dt FROM dual CONNECT BY level <=(TO_DATE(EndDate)-TO_DATE(StartDate)))
where to_char (dt,'D')<>1

Happy coding.

Friday, March 12, 2010

String To Pdf Converter

This dll helps you to convert your string format data into pdf file
follow the steps to implement it.
The Pdf will be available from http://www.box.net/CSharpControls

download StringToPdf.dll to your computer
1. Do right-click on your Application REFERENCES folder available in Solution Explorer(As shown in the below figure)

2. Click on Add Reference and the following window will be opened.





3. go on the 4th tab and locate your downloaded stringToPdf.dll and click ok. (here my .dll's location is Desktop)
4. Now make an object of the class PDFWRITER
here is the example
string text = "Markand's Pdf.dll Testing";
PdfWriter p = new PdfWriter();
p.write(text);
this will write the content of "text" into .pdf file
You can find your .pdf file at C:\Temp\
That's All.
Enjoy Converting from string to PDF

Saturday, February 6, 2010

PhotoChanger.dll



PhotoChanger.dll is used to change the photo for every specified time interval.
This control takes the path of the Image Folder and show all images one by one.

dll will be available from http://depositfiles.com/files/ir3oojbta

follow the steps to add control to your toolbox of C#

1. Right click on toolbox. and select "Choose Items" from the context menu.
2. Select "Browse" from the opened dialog box.
3. select the .dll stored in your computer and click ok.
4. Now see in the toolbox your control is ready to use.

5.now drag control to your window application

6.select control's property.

7.give Folder path in property named "ImageFolder"
8. Give Time Interval (time to reload next photo) in property named "Interval" in milliseconds

Thats all.