Paresh

Visual Studio "14" CTP Now Available

Visual Studio "14" CTP Now Available.
Some detail available at http://blogs.msdn.com/b/csharpfaq/archive/2014/06/03/visual-studio-14-ctp-now-available.aspx

You download it from : http://www.visualstudio.com/en-us/downloads/visual-studio-14-ctp-vs.aspx

Visual Studio "14" CTP release note : http://support.microsoft.com/kb/2967191

Getting Started with ASP.NET vNext and Visual Studio "14"  : http://www.asp.net/vnext/overview/aspnet-vnext/getting-started-with-aspnet-vnext-and-visual-studio

Warning:
Visual Studio "14" CTPs have known compatibility issues with previous releases of Visual Studio and should not be installed side-by-side on the same computer.

Better to install it on Virtual Machine.

Send mail using gmail

   1:  void sendEmail(string strFrom, string strTo, string strSubject, string strBody)
   2:      {
   3:          System.Net.Mail.MailMessage objMailMessage 
   = new System.Net.Mail.MailMessage();
   4:          objMailMessage.To.Add(strTo);
   5:          objMailMessage.From 
   = new MailAddress(strFrom, "", System.Text.Encoding.UTF8);
   6:          objMailMessage.Subject = strSubject;
   7:          objMailMessage.SubjectEncoding = System.Text.Encoding.UTF8;
   8:          objMailMessage.Body = strBody;
   9:          objMailMessage.BodyEncoding = System.Text.Encoding.UTF8;
  10:          objMailMessage.IsBodyHtml = true;
  11:          objMailMessage.Priority = MailPriority.High;
  12:   
  13:          SmtpClient objSmtpClient = new SmtpClient();
  14:   
  15:          objSmtpClient.Credentials = new System.Net.NetworkCredential(strFrom, "");
  16:   
  17:          objSmtpClient.Host = "smtp.gmail.com";
  18:          objSmtpClient.Port = 587;
  19:          objSmtpClient.EnableSsl = true;
  20:   
  21:          objSmtpClient.Send(objMailMessage);
  22:      }

Ajax progress for History Control

Sometime with Ajax History control on page, when user presses back or forward button it takes time to load page content. because History’s ajax request is still in progress. user gets effect after few seconds. and this ajax request does not display update progress. sometime it is needed ajax progress for History control. so user comes to know that he will get actual content after ‘Loading…’ message gets hidden.

To display update progress first we have to identify that ajax request being started and it is going to be started by History control. and on completion of request stop displaying ajax progress.

first we add beginRequest and endRequest handler function.

function pageLoad(sender, args)
{
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
}



‘pageLoad’ function will be fired automatically when client side page is loaded. so it will set handler function for beginRequest and endRequest.



the handler functions:



function BeginRequestHandler(sender, args)
{
 var elem = args.get_postBackElement();
 if(elem.id=='<%= History1.ClientID %>')  //-- To identify event sender is History Control.
 {
  //-- get update panel object and make it visible.
  var uPanel = obj=document.getElementById('<%=Updateprogress1.ClientID%>');
  if(uPanel)
   uPanel.style.display="block";
 }
}    
function EndRequestHandler(sender, args)
{
 //-- get update panel object and hide it.
 var uPanel = obj=document.getElementById('<%=Updateprogress1.ClientID%>');
 if(uPanel)
   uPanel.style.display="none";
}


Now its done.

it will show you 'Loading..'(whatever you have put in update progress) while you will press browser's back button it it takes logn time to load content.


if you are using any third party controls, like Telerik, they provides you javascript API to show/hide update/ajax panel. you can use that API in these handler functions.