Thursday, October 15, 2015

Logging into database using Enterprise Logging


Database _database = DatabaseFactory.CreateDatabase();
DbCommand _command = _database.GetStoredProcCommand("STOREDPROCEDURENAME");
_database.AddInParameter(_command, "@FIELDNAME", DbType.String, "FIELDVALUE");
_database.ExecuteNonQuery(_command);

Wednesday, July 22, 2015

Get the query string value from URL using javascript

 function getQueryString(key){
         var regex=new RegExp('[\\?&]'+key+'=([^&#]*)');
         var qs=regex.exec(window.location.href);
         return qs[1];
       }

Friday, February 20, 2015

Print a selected area on a page

On the style tag add the below contents

style type="text/css" media="print"
.no-print { display: none; }

The contents which do not have to be printed can be given under a div tag with the class name "no=print"


Friday, February 13, 2015

Upload multiple files using jQuery plugin


  • Refer the jquery.MultiFile.js
  • Add a ASP.Net file upload control to the page
  • Add the following code on the button click event for uploading the files

HttpFileCollection fileCollection = Request.Files;
for (int i = 0; i < fileCollection.Count; i++)
{
    HttpPostedFile uploadfile = fileCollection[i];
    string fileName = Path.GetFileName(uploadfile.FileName);
    if (uploadfile.ContentLength > 0)
    {
        uploadfile.SaveAs(Server.MapPath("~/UploadedFiles/") + fileName);
        lblMessage.Text += fileName + "Saved!!!";
    }
}

The multiple file upload plugin can be downloaded from here

Friday, January 23, 2015