Wednesday, April 6, 2011

How to support SSL for JQuery CDN

Google and Microsoft both support https.
<script type="text/javascript"
<script src="" type="text/javascript"></script> 

How to make full screen div by css

<style type="text/css">
    left:0;    width:100%;

What is Viewbag in ASP.NET MVC

The ViewBag object is a wrapper on ViewData object. So you can access ViewData without data type converting in html.

Code example:

In controller

        public ActionResult Index()


            ViewBag.TestName = "teststring";

            return View();


In cshtml:





   @ViewData["TestName"] is equal to  @ViewBag.TestName in here


You can use strong type data in html view by Viewbag.

It is a new feature in ASP.NET MVC 3 to pass data from Controllers to Views as same as ViewData.
But Viewbag is the dynamic type.
    My name is
    <b><%: ViewData["name"] %></b>,
    <b><%: ViewData["age"] %></b> years old.
    <br />  
    I like the following colors:
    My name is
    <b><%: ViewBag.Name %></b>,
    <b><%: ViewBag.Age %></b> years old.
    <br />  
    I like the following colors:

ActionResults explained in ASP.NET MVC

Action results are an important part of the ASP.NET MVC controller system, and definitely worth taking a good look at. Understanding how they work gives you many more choices in MVC and that will certainly help make your code better.