Archive for the ‘html’ Category

Free Microsoft Training…

Courses by Topics

  • C# / XAML
  • HTML5
  • Virtualization
  • Managing Desktop & Devices
  • Server Infrastructure
  • Management & Security
  • Private Cloud
  • Business Intelligence
  • Collaboration
  • Licensing
  • App Development

Courses by Products

  • Windows
  • Windows Server
  • Visual Studio
  • System Center
  • SQL Server
  • Windows Azure
  • Office

Link: http://www.microsoftvirtualacademy.com/

Join me and Christopher Harrison (@geektrainer) for a free, full day online training event on Developing ASP.NET MVC4 Web Applications! There’s still space available, so register now.

MVA - ASP.NET MVC 4 Jump Start

Microsoft Virtual Academy (MVA) runs great, high quality live training events. Earlier this year, I had the opportunity to participate in the Building Web Apps with ASP.NET Jump Start with Scott Hanselman and Damian Edwards. For that event, we overviewed the Microsoft web platform, including a lot of new and preview features.

For this upcoming event, we’re going to be sticking closer to the curriculum for the Developing ASP.NET MVC 4 Web Applications certification exam (70-486) curriculum. Christopher is a full time, professional instructor (MCT, MCPD, MCITP) who’s helped people prepare for this exam, and we’re going to be basing the Jump Start content on what you’d learn in a 70-486 certification course.

Here’s an overview of what we’re planning to cover:

  • Overview of MVC
    • What is MVC?
    • How is MVC different from Web Forms?
    • Why use MVC?
  • Developing ASP.NET MVC 4 Controllers and Models
    • Creating Controllers
    • Adding Actions
    • Creating MVC Models
    • Working with Code First
  • Developing ASP.NET MVC 4 Views
    • Razor Syntax
    • HTML Helpers
    • Partial Views
  • Integrating JavaScript and MVC
    • Using AJAX
    • Using jQuery
  • Implementing Web APIs
    • Developing Web API Controllers
    • Calling HTTP Services from Client-Side Code
  • Deploying ASP.NET MVC Site Walkthrough
    • Creating a site on Windows Azure Web Sites
    • Deploying an ASP.NET MVC Application with Visual Studio Web Deploy
  • What’s Next and Resources
    • Sneak peak at Visual Studio 2013 (Preview) and ASP.NET MVC 5 tooling
    • A look at real-time communications with SignalR
    • Resources for keeping up with new ASP.NET releases

Note that this is a Jump Start to help you get started preparing for the certification exam, but with a one day event we’re only covering a portion of the content that’s on the exam. Don’t expect to watch this and breeze through the exam… but it’s a start.

And if you’re just new to ASP.NET MVC and want a full day (free!) day of training, this is a great opportunity. We’re working off some of the certification content, but you don’t need to be working towards the certification to take or benefit from the class.

To get you warmed up for it, here’s the one hour introduction to ASP.NET MVC 4 from the Building Web Apps with ASP.NET Jump Start this past February.

Gets the attachment collection used to store alternate forms of the message body.

 

Use the AlternateViews property to specify copies of an e-mail message in different formats. For example, if you send a message in HTML, you might also want to provide a plain text version in case some of the recipients use e-mail readers that cannot display HTML content.

To add an alternate view to a MailMessage object, create an Attachment for the view, and then add it to the collection returned by AlternateViews. Use the Body property to specify the text version and use the AlternateViews collection to specify views with other MIME types. Use the MediaTypeNames class members to specify the MIME type for the alternate view.

The following code example demonstrates creating and sending an e-mail message with a plain text and an HTML alternate view.


		public static void CreateMessageWithMultipleViews(string server, string recipients)
		{
			// Create a message and set up the recipients.
			MailMessage message = new MailMessage(
				"jane@contoso.com",
				recipients,
				"This e-mail message has multiple views.",
				"This is some plain text.");

			// Construct the alternate body as HTML.
			string body = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">";
			body += "<HTML><HEAD><META http-equiv=Content-Type content=\"text/html; charset=iso-8859-1\">";
			body += "</HEAD><BODY><DIV><FONT face=Arial color=#ff0000 size=2>this is some HTML text";
			body += "</FONT></DIV></BODY></HTML>";

			ContentType mimeType = new System.Net.Mime.ContentType("text/html");
			// Add the alternate body to the message.

			AlternateView alternate = AlternateView.CreateAlternateViewFromString(body, mimeType);
			message.AlternateViews.Add(alternate);

			// Send the message.
			SmtpClient client = new SmtpClient(server);
			client.Credentials = CredentialCache.DefaultNetworkCredentials;

      try {
			  client.Send(message);
			}
			catch (Exception ex) {
			  Console.WriteLine("Exception caught in CreateMessageWithMultipleViews(): {0}",
                    ex.ToString() );
      }
			// Display the values in the ContentType for the attachment.
			ContentType c = alternate.ContentType;
			Console.WriteLine("Content type");
			Console.WriteLine(c.ToString());
			Console.WriteLine("Boundary {0}", c.Boundary);
			Console.WriteLine("CharSet {0}", c.CharSet);
			Console.WriteLine("MediaType {0}", c.MediaType);
			Console.WriteLine("Name {0}", c.Name);
			Console.WriteLine("Parameters: {0}", c.Parameters.Count);
			foreach (DictionaryEntry d in c.Parameters)
			{
				Console.WriteLine("{0} = {1}", d.Key, d.Value);
			}
			Console.WriteLine();
			alternate.Dispose();
		}

 

Source: http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.alternateviews.aspx

If you do not need to handle iframe content from a different domain, try this code, it will solve the problem completely and it’s simple:

<script language="JavaScript">
<!--
function autoResize(id){
    var newheight;
    var newwidth;

    if(document.getElementById){
        newheight=document.getElementById(id).contentWindow.document .body.scrollHeight;
        newwidth=document.getElementById(id).contentWindow.document .body.scrollWidth;
    }

    document.getElementById(id).height= (newheight) + "px";
    document.getElementById(id).width= (newwidth) + "px";
}
//-->
</script>

<i frame src="usagelogs/default.aspx" width="100%" height="200px" id="iframe1" marginheight="0" frameborder="0" onLoad="autoResize('iframe1');"></iframe>

Important:

onLoad="autoResize('iframe1');" //this is executed after load frame

Source: http://goo.gl/a4hao