Monday, October 20, 2008

get the information about the operating system name space System.Environment

The class System.Environment is used to retrieve information about the operating system. Some of the static members of this class are as follows:
1) Environment .OSVersion - Gets the version of the operating system
2) Environment .GetLogicalDrives() - method that returns the drives
3) Environment .Version - returns the .NET version running the application
4) Environment .MachineName - Gets name of the current machine
5) Environment .Newline - Gets the newline symbol for the environment
6) Environment .ProcessorCount - returns number of processors on current machine
7) Environment .SystemDirectory - returns complete path to the System Directory
8) Environment .UserName - returns name of the entity that invoked the application

Thanks
Help on Desk Team

JAVASCRIPT FOR REFRESH PARENT and UPDATE WINDOW FROM CHILED WINDOW

HI
HERE WE HAVE JAVASCRIPT FOR REFRESH PARENT and UPDATE WINDOW FROM CHILED WINDOW
AND CHANGE PARENT WINDOW CONTROL VALUE FROM CHILED WINDOW AFTWER SOME OPRATION .

a) refresh parent window:-
window . opener . location . reload();

function refreshParent() {
window . opener . location . reload();

window . opener . location . href = window . opener . location . href;

if (window . opener . progressWindow)

{
window . opener . progressWindow . close()
}
// window . close();
return false;
}

[asp:Button ID="btn2" runat="Server" Text="refreshParent" OnClientClick="refreshParent();" /]

b) PASS VALUE FROM CHILD WINDOW TO PARENT WINDOW

protected void btn_Click(object sender, EventArgs e)
{
//{window.opener.location.reload(); }
int intSum;

intSum = Convert . ToInt32(txt1 . Text) + Convert.ToInt32(TextBox1 . Text);

Page.ClientScript . RegisterStartupScript(this.GetType(), "close", "");
// lbl is control of parent window

}


c)

protected void btnSum_Click(object sender, EventArgs e) { //SumAndGO(varValue) int sum = Convert.ToInt32(TxtNum1 . Text) + Convert.ToInt32(TxtNum2 . Text); string Jscript = "SumAndGO(" + sum + ")"; Jscript = ""; ClientScript.RegisterStartupScript(this . GetType(), "Jscript", Jscript); }


Thanks
Help on desk

Wednesday, October 15, 2008

How to read a webpage from onother website

//-
using System.IO;
using System.Text;
using System.Net;



string ddate = string.Empty;

WebRequest req = WebRequest.Create("http://www.helpondesk.com/exaple");
WebResponse resp = req.GetResponse();

Stream s = resp.GetResponseStream();
StreamReader sr = new StreamReader(s, Encoding.ASCII);
string doc = sr.ReadToEnd();

Thanks
Helpondesk Team

Complete example of create Thumbnail when we uplaod image

how to create a thumnain while we are uploading a new image


Code in aspx page

protected void Button1_Click(object sender, EventArgs e)
{
string filename = string.Empty;
string imagename = string.Empty;

string imgtype = string.Empty;
thumbnail thumb = new thumbnail();
filename = fileUpload.PostedFile.FileName;
imagename = filename.Substring(filename.LastIndexOf("\\") + 1, (filename.LastIndexOf(".") - 1) -

(filename.LastIndexOf("\\")));
imgtype = filename.Substring(filename.LastIndexOf("."));

string str = thumb.UploadImage(imagename, imgtype, Server.MapPath(@"Images\Actual\"),

Server.MapPath(@"Images\Thumbnail\"), fileUpload,95,143);

}

code in HTML part :-

< asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" / >

< asp:FileUpload ID="fileUpload" runat="server" / >

Code in class file

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
//----
using System.Drawing;
using System.Drawing.Imaging;

///
/// Summary description for thumbnail
///

public class thumbnail
{
public thumbnail()
{
//
// TODO: Add constructor logic here
//
}


public string UploadImage(string filename, string filetype, string str_folder_name_main, string str_folder_name_small,

FileUpload fileupload1, int width, int heigh)
{

if (fileupload1.PostedFile.ContentType == "image/pjpeg" || fileupload1.PostedFile.ContentType == "image/jpeg" ||

fileupload1.PostedFile.ContentType == "image/bmp" || fileupload1.PostedFile.ContentType == "image/gif")
{
fileupload1.PostedFile.SaveAs(str_folder_name_main + filename + filetype);
CreateThumbnail(str_folder_name_main + filename + filetype, width , heigh , str_folder_name_small + filename +

filetype);
// CreateThumbnail(str_folder_name_main + filename + filetype, 250, 300, str_folder_name_large + filename +

filetype);
return "1";
}
else
{
return "2";
}
}

public void CreateThumbnail(string lcFilename, int lnWidth, int lnHeight, string OutputFilename)
{
System.Drawing.Bitmap bmpOut = null;
Bitmap loBMP = new Bitmap(lcFilename);
ImageFormat loFormat = loBMP.RawFormat;
decimal lnRatio;
int lnNewWidth = 0;
int lnNewHeight = 0;
lnNewWidth = lnWidth;
lnNewHeight = lnHeight;
bmpOut = new Bitmap(lnNewWidth, lnNewHeight);
Graphics g = Graphics.FromImage(bmpOut);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.FillRectangle(Brushes.White, 0, 0, lnNewWidth, lnNewHeight);
g.DrawImage(loBMP, 0, 0, lnNewWidth, lnNewHeight);
loBMP.Dispose();

bmpOut.Save(OutputFilename, ImageFormat.Jpeg);
bmpOut.Dispose();


}

public bool checkImageType(HtmlInputFile FileUpload1)
{
if (FileUpload1.PostedFile.ContentType == "image/pjpeg" || FileUpload1.PostedFile.ContentType == "image/jpeg" ||

FileUpload1.PostedFile.ContentType == "image/bmp" || FileUpload1.PostedFile.ContentType == "image/gif")
{
return true;
}
else
{
return false;
}
}

}

Thanks
helpondesk Team