Tuesday, 1 April 2014
Update progress bar using update progress ajax asp.net
<asp:UpdateProg ress ID="UpdateProgr ess1" runat="server" DisplayAfter="0 ">
<ProgressTempla te>
<div id="IMGDIV11" runat="server" align="center" style="visibili ty: visible;
vertical-align: middle; width: 100%; position:fixed; height:100%;
z-index: 999999; margin-top: -150px; margin-left: -10px;"
valign="middle" class="modalBac kground">
<asp:Image ID="Image11" runat="server" Style="position : relative; top: 40%; left: 0px;"
Height="120px" ImageUrl="~/Ima ges/progress2.g if" />
</div>
</ProgressTempl ate>
</asp:UpdatePro gress>
<ProgressTempla
<div id="IMGDIV11" runat="server" align="center" style="visibili
vertical-align: middle; width: 100%; position:fixed; height:100%;
z-index: 999999; margin-top: -150px; margin-left: -10px;"
valign="middle" class="modalBac
<asp:Image ID="Image11" runat="server" Style="position
Height="120px" ImageUrl="~/Ima
</div>
</ProgressTempl
</asp:UpdatePro
Monday, 31 March 2014
Check Date formate and convert in datetime using c#
string dd =lbldt.Text.Substring(0, lbldt.Text.Length - (lbldt.Text.Length - 2));
string [] pp = dd.Split('/');
if (Convert.ToInt32(pp[0]) < 12)
{
ldatet = Convert.ToDateTime(lbldt.Text, CultureInfo.InvariantCulture);
}
else
{
ldatet = Convert.ToDateTime(lbldt.Text, CultureInfo.CreateSpecificCulture("en-AU").DateTimeFormat);
}
string [] pp = dd.Split('/');
if (Convert.ToInt32(pp[0]) < 12)
{
ldatet = Convert.ToDateTime(lbldt.Text, CultureInfo.InvariantCulture);
}
else
{
ldatet = Convert.ToDateTime(lbldt.Text, CultureInfo.CreateSpecificCulture("en-AU").DateTimeFormat);
}
Convert datetime dd/mm/yyyy to mm/dd/yyyy using c#
string dt= DateTime.ParseExact("28/08/2012", "dd/MM/yyyy", CultureInfo.InvariantCulture).ToString("MM/dd/yyyy", CultureInfo.InvariantCulture);
//Converting DateTime
Convert.ToDateTime(lbldt.Text, CultureInfo.CreateSpecificCulture("en-AU").DateTimeFormat);
//Converting DateTime
Convert.ToDateTime(lbldt.Text, CultureInfo.CreateSpecificCulture("en-AU").DateTimeFormat);
Thursday, 20 February 2014
Import Bulk Images from Client to server using asp.net with IONIC.Zip
public void ImportImages(string path, string fname)
{
try
{
using (ZipFile zip1 = ZipFile.Read(path))
{
zip1.ExtractAll(Server.MapPath("~/UserImages"), ExtractExistingFileAction.OverwriteSilently);
}
string sdir = path.Substring(0, path.IndexOf('.'));
string destDirName = Server.MapPath("~/UserImages/");
DirectoryInfo dir = new DirectoryInfo(sdir);
FileInfo[] files = dir.GetFiles();
foreach (FileInfo file in files)
{
String ext = System.IO.Path.GetExtension(file.FullName);
if (ext.ToLower() == ".jpg" || ext.ToLower() == ".png" || ext.ToLower() == ".gif" || ext.ToLower() == ".bmb")
{
string temppath = Path.Combine(destDirName, file.Name);
file.CopyTo(temppath, true);
}
}
//delete file
if (File.Exists(path))
{
File.Delete(path);
}
//delete directory
if (Directory.Exists(sdir))
{
Directory.Delete(sdir,true);
}
}
catch (Exception ex)
{
string mmsg = ex.Message;
showEXPMessages("(ImportImages) " + mmsg); showMessages(mmsg);
}
}
{
try
{
using (ZipFile zip1 = ZipFile.Read(path))
{
zip1.ExtractAll(Server.MapPath("~/UserImages"), ExtractExistingFileAction.OverwriteSilently);
}
string sdir = path.Substring(0, path.IndexOf('.'));
string destDirName = Server.MapPath("~/UserImages/");
DirectoryInfo dir = new DirectoryInfo(sdir);
FileInfo[] files = dir.GetFiles();
foreach (FileInfo file in files)
{
String ext = System.IO.Path.GetExtension(file.FullName);
if (ext.ToLower() == ".jpg" || ext.ToLower() == ".png" || ext.ToLower() == ".gif" || ext.ToLower() == ".bmb")
{
string temppath = Path.Combine(destDirName, file.Name);
file.CopyTo(temppath, true);
}
}
//delete file
if (File.Exists(path))
{
File.Delete(path);
}
//delete directory
if (Directory.Exists(sdir))
{
Directory.Delete(sdir,true);
}
}
catch (Exception ex)
{
string mmsg = ex.Message;
showEXPMessages("(ImportImages) " + mmsg); showMessages(mmsg);
}
}
Create Zip and download file using IONIC.ZIP in asp.net
public void crateZip()
{
FileStream fs = null;//, fs2=null;
try
{
string strFName= Session["FileName"]!=null?Session["FileName"].ToString():"";
string destination= Session["FileLocation"] != null?Session["FileLocation"].ToString():"";
string filep = Request.PhysicalApplicationPath + "FolderName//";
string datafolder =filep+ strFName.Substring(0, strFName.Length-4);
string foldername=strFName.Substring(0, strFName.Length - 4);
string path = Server.MapPath("~/FolderName/" + foldername+"/");
string[] filenames = Directory.GetFiles(path);
using (ZipFile zip = new ZipFile())
{
zip.AddFile(destination,"");
zip.AddFiles(filenames, foldername);
zip.Save(Server.MapPath("~/" + foldername + ".zip"));
}
string zipFullPath = Server.MapPath("~/" + foldername + ".zip");
string strPath;
strPath = Session["FileLocation"].ToString();
string strFileName;
strFileName = Session["FileName"].ToString();
//fs=new FileStream();
fs = File.Open(zipFullPath, FileMode.Open);
byte[] bytBytes = new byte[(fs.Length)];
fs.Read(bytBytes, 0, (int)fs.Length);
fs.Close();
Response.AddHeader("Content-disposition", "attachment; filename=" + foldername + ".zip");
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(bytBytes);
if (File.Exists(strPath))
{
System.IO.File.Delete(strPath);
}
if (File.Exists(zipFullPath))
{
System.IO.File.Delete(zipFullPath);
}
if (Directory.Exists(path))
{
Directory.Delete(path,true);
}
Response.Flush();
Response.End();
}
catch (System.Exception ex)
{
}
finally { fs.Dispose(); Response.Clear();}
}
{
FileStream fs = null;//, fs2=null;
try
{
string strFName= Session["FileName"]!=null?Session["FileName"].ToString():"";
string destination= Session["FileLocation"] != null?Session["FileLocation"].ToString():"";
string filep = Request.PhysicalApplicationPath + "FolderName//";
string datafolder =filep+ strFName.Substring(0, strFName.Length-4);
string foldername=strFName.Substring(0, strFName.Length - 4);
string path = Server.MapPath("~/FolderName/" + foldername+"/");
string[] filenames = Directory.GetFiles(path);
using (ZipFile zip = new ZipFile())
{
zip.AddFile(destination,"");
zip.AddFiles(filenames, foldername);
zip.Save(Server.MapPath("~/" + foldername + ".zip"));
}
string zipFullPath = Server.MapPath("~/" + foldername + ".zip");
string strPath;
strPath = Session["FileLocation"].ToString();
string strFileName;
strFileName = Session["FileName"].ToString();
//fs=new FileStream();
fs = File.Open(zipFullPath, FileMode.Open);
byte[] bytBytes = new byte[(fs.Length)];
fs.Read(bytBytes, 0, (int)fs.Length);
fs.Close();
Response.AddHeader("Content-disposition", "attachment; filename=" + foldername + ".zip");
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(bytBytes);
if (File.Exists(strPath))
{
System.IO.File.Delete(strPath);
}
if (File.Exists(zipFullPath))
{
System.IO.File.Delete(zipFullPath);
}
if (Directory.Exists(path))
{
Directory.Delete(path,true);
}
Response.Flush();
Response.End();
}
catch (System.Exception ex)
{
}
finally { fs.Dispose(); Response.Clear();}
}
Export images from web to Client
public void CopyFiles(string sourcePath, string destinationPath, string sFileName)
{
try
{
string Sfilepthe = sourcePath + "\\" + sFileName;
string Sdestination = destinationPath + "\\" + sFileName;
if (File.Exists(Sfilepthe))
{
File.Copy(Sfilepthe, Sdestination, true);
}
}
catch (Exception ex)
{
string mmsg = ex.Message;
showEXPMessages("(CopyFiles) " + mmsg);// showMessages(mmsg);
}
}
{
try
{
string Sfilepthe = sourcePath + "\\" + sFileName;
string Sdestination = destinationPath + "\\" + sFileName;
if (File.Exists(Sfilepthe))
{
File.Copy(Sfilepthe, Sdestination, true);
}
}
catch (Exception ex)
{
string mmsg = ex.Message;
showEXPMessages("(CopyFiles) " + mmsg);// showMessages(mmsg);
}
}
Subscribe to:
Posts (Atom)
How to highlight selected text in notepad++
–> To highlight a block of code in Notepad++, please do the following steps step-1 :- Select the required text. step-2 :- Right click...
-
Encryption / Decryption: Encryption is the process of translating plain text data into something that appears to be random and...
-
//////// CSS < style > .validated_ok { border : 1px solid green } .validated_error { border : 1px solid red } .validate...
-
Excel :: Text :: 1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula :: TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...