Category Archives: ASP .Net

Timezone your DateTime

Hi there!

I have been wondering today on how to make your website created on ASP .Net  perfect to all timezone so that if a user view your website on another country the date and time of your website is set to their timezone. So lets start to Timezone your DateTime!

  1. First create a Website Project on your Visual Studio
  2. Add Reference to this DateTimeW DLL
  3. On your website there should be an AJAX – Server Interaction. The AJAX will pass the timezone of the client to the Server and the server will fetch the timezone and set all your date.

For a clear way of implementing this your can download the demo below.

Demo TimezoneDatetime

jQuery Extension for ASP .Net MVC

My boss told us to search for a jQuery Extension for ASP .Net MVC to make the development easier. After minutes of searching the web I have found two extensions that you and I can use:

  1. DJME 2 which is an free and Open source
  2. Telerik Extensions for ASP .NET in this case is a paid extension

Both extensions utilizes the creation of custom helper to make jQuery development quite easier but abstracted. Abstracted because you are learning how the extensions should be use to produce jQuery but your not really coding jQuery. 

So in the end, I will still recommend using jQuery it self, doing all the hard works of creating the JavaScript file and code all the way, so you can produce the right jQuery output you have ever wanted.

ASP .Net MVC 3 – WebMail

Hi,

I have been searching the web on how to easily send email thru ASP .NET MVC 3 and finally found the right code for it, its called WebMail. Look at the code below and insert it to one of your Controller’s Action:

WebMail.SmtpServer = “smtp.gmail.com”;
WebMail.EnableSsl = true;
WebMail.SmtpPort = 25;
WebMail.UserName = “tjpublic1@gmail.com”;
WebMail.Password = “**********”;
WebMail.From = “tjpublic1@gmail.com”;
WebMail.Send(“********@******.com”, subject:”Subject”, body:”Message Here”);

Then try it on!

Its the Easiest Email on ASP .Net mvc 3 using webmail using gmail!

SQL Server Report Service

Time to remember an old friend on creating a report on ASP .Net, the Sql Server Report Service also known as SSRS. SSRS utilizes the MS SQL Server that simplifies the creation of report. The Concept is that you separate the location where your report is located so that even if your website is down you can still provide report and use it on other web programming language by putting it in an iFrame.

Upon reviewing here are the sites that made me remember:

In addition, SSRS need SQL Business Intelligence Development Studio (BIDS) in order to create reports and deploy directly these reports to the server.

ASP .Net MVC 3 File Upload

Doing File Upload in ASP .Net MVC 3 is easier than ASP .Net Web Form. On this example Only two controller and one view is needed to perform this task.

Controller

public class FileController : Controller
    {
        //
        // GET: /File/
 
        public ActionResult Index()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Upload(HttpPostedFileBase f)
        {
            if (f.ContentLength > 0)
            {
                string filePath = Path.Combine(HttpContext.Server.MapPath(“\\Uploads\\”), Path.GetFileName(f.FileName));
                f.SaveAs(filePath);                
            }
            return RedirectToAction(“Index”);
        }
 
    }
 
View
@{
    ViewBag.Title = “Index”;
}
 
<h2>Index</h2>
 
@using (Html.BeginForm(“Upload”, “File”, FormMethod.Post, new { enctype = “multipart/form-data” }))
{
    @Html.ValidationSummary(true)
 
    <input type=”file” name=”f” /><br />
    <input type=”submit” value=”Submit” />
}
 
Thats it. 
 
Download the source Here

public class FileController : Controller    {        //        // GET: /File/
        public ActionResult Index()        {            return View();        }        [HttpPost]        public ActionResult Upload(HttpPostedFileBase f)        {            if (f.ContentLength > 0)            {                string filePath = Path.Combine(HttpContext.Server.MapPath(“\\Uploads\\”), Path.GetFileName(f.FileName));                f.SaveAs(filePath);                            }            return RedirectToAction(“Index”);        }
    }