ChildActionOnly using PartialViewResult. in Asp.Net MVC

How to use ChildActionOnly in Asp.Net MVC using PartialViewResult.

1>Create a Project name it TestApplication.
   
2>Home Controller create by Default here.Let use  Index Action.

3> In Index Action Write a logic to display "This is My Index Page."
     Include with Datetime.Now.































4>Create a view page for an Index Page.
    Call the Field for display the Message.
        @viewbag.Message="This is My Index Page";
        @Model.Date for display date and time.
     
    5> Call PartialView NowDate Action.
         Syntax : @Html.Action("NowDate"); in Index view.

6>Create Child Action "NowDate()", use attribute "ChildActionOnly" ,So that we can link with Index Action.
write a logic in Controller side for NowDate Action,
   
   [ChildActionOnly]
        public PartialViewResult NowDate()
        {
            ViewBag.Message = "This is Now Date page using child action only.";
            var model = DateTime.Now;
            return PartialView(model);
        }

  7> Create partial view for NowDate();
        call the field to display.
































7>Now Run the project. 



8> If you try to pass Child Action  "NowDate" to browser url .
      ex:-  localhost:1673/Home/NowDate
         It will give error.












Share this

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
:-?
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
$-)
(y)
(f)
x-)
(k)
(h)
cheer