{"id":1673,"date":"2017-07-21T14:18:07","date_gmt":"2017-07-21T08:48:07","guid":{"rendered":"http:\/\/stepbystepschools.net\/?p=1673"},"modified":"2017-07-21T14:18:07","modified_gmt":"2017-07-21T08:48:07","slug":"asp-net-mvc-queries-part-1","status":"publish","type":"post","link":"https:\/\/www.stepbystepschools.net\/?p=1673","title":{"rendered":"ASP.NET MVC Queries \u2013 Part 1."},"content":{"rendered":"<p>This query was asked by one of students who had attended MVC training in Mumbai past week. Below are the questions and answers , can be useful for some students.<\/p>\n<ol>\n<li>In lab 3 the one with View data-U mentioned we can\u2019t have server controls, viewstate and code behind but if we use aspx instead of a cshtml page for VIEW then we could have the above 3 is it? The above three attributes are specific to Razor syntax and not MVC right?\n<p><strong><br \/>\nAnswer :-<\/strong> Yes you can have above code in ASPX as well. They are not really specific to Razor they are MVC codes. You can use them in MVC controller code also.<\/li>\n<li>In lab 3 you used Mytime property without declaring it with type dynamic i.e u directy assigned value to it -&#8221; Viewbag. Mytime = datetime. Now. Tostring() &#8220;. So how is viewbag able to read the property mytime. Is mytime a keyword or an identifier?I also saw the difference between dynamic and reflection video but it couldn&#8217;t help me solve this doubt.\n<p><strong><br \/>\nAnswers :-<\/strong> Its uses reflection. In other words on runtime it checks for that property.<\/li>\n<li>Does Cshtml page use only Razor syntax?or Can Razor syntax be implemented only in Cshtml page?\n<p><strong><br \/>\nAnswer :-<\/strong> Razor syntax is for CSHTML. CSHTML is a file extension.<\/li>\n<li>In lab 5 Why did you tag the &#8220;Customer&#8221; model to &#8220;Load View&#8221; or &#8220;Customer View&#8221; and why not &#8220;EnterCustomer&#8221; view.<\/li>\n<li>Can we have a model for &#8220;EnterCustomer&#8221; view as well?\n<p><span style=\"text-decoration: underline;\">For example :-<\/span>We want to take many inputs from user but want to display only a few. And save the rest in db so that those properties could be used in some other page.<br \/>\nIn such case what should be the model design.<br \/>\n<strong><br \/>\nAnswer :-<\/strong> Yes you can have for EnterCustomer. Same model can be used with different models. Use inheritance in that case. So create a class with X number of properties. And if you want X+10 more properties then inherit and create a new class.<\/li>\n<li>Also in lab 5 you did not use &#8220;ViewData&#8221; or &#8220;ViewBag&#8221; for passing data from controller to view. You did it using the customer object directly. Why is that so?\n<p><strong><br \/>\nAnswer :-<\/strong> Viewdata and viewbag should be the last resort. They should be used in rare cases where you have hanging properties like date time , some IDs and so on. But when it comes to Business objects like Customer , Supplier you should use strongly typed model object(return view(&#8220;Test&#8221;,CustomerObject).<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This query was asked by one of students who had attended MVC training in Mumbai past week. Below are the questions and answers , can be useful for some students. In lab 3 the one with View data-U mentioned we &hellip; <a href=\"https:\/\/www.stepbystepschools.net\/?p=1673\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":40,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[74,1,3,75],"tags":[179,47,76],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v18.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>ASP.NET MVC Queries \u2013 Part 1. - Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.stepbystepschools.net\/?p=1673\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"ASP.NET MVC Queries \u2013 Part 1. - Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai\" \/>\n<meta property=\"og:description\" content=\"This query was asked by one of students who had attended MVC training in Mumbai past week. Below are the questions and answers , can be useful for some students. In lab 3 the one with View data-U mentioned we &hellip; Continue reading &rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.stepbystepschools.net\/?p=1673\" \/>\n<meta property=\"og:site_name\" content=\"Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai\" \/>\n<meta property=\"article:published_time\" content=\"2017-07-21T08:48:07+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"StepByStepSchoolsSupport\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.stepbystepschools.net\/#website\",\"url\":\"https:\/\/www.stepbystepschools.net\/\",\"name\":\"Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai\",\"description\":\"MVC 5\/Core, AngularJS 1.x, 2.0, 4.0, Design Pattern, Architecture, SSIS, SSAS, SSRS, Data Science, Big data, Hadoop classroom training\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.stepbystepschools.net\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.stepbystepschools.net\/?p=1673#webpage\",\"url\":\"https:\/\/www.stepbystepschools.net\/?p=1673\",\"name\":\"ASP.NET MVC Queries \u2013 Part 1. - Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai\",\"isPartOf\":{\"@id\":\"https:\/\/www.stepbystepschools.net\/#website\"},\"datePublished\":\"2017-07-21T08:48:07+00:00\",\"dateModified\":\"2017-07-21T08:48:07+00:00\",\"author\":{\"@id\":\"https:\/\/www.stepbystepschools.net\/#\/schema\/person\/7131e4ee1c5673879e6029d14ec2f655\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.stepbystepschools.net\/?p=1673#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.stepbystepschools.net\/?p=1673\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.stepbystepschools.net\/?p=1673#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.stepbystepschools.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"ASP.NET MVC Queries \u2013 Part 1.\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.stepbystepschools.net\/#\/schema\/person\/7131e4ee1c5673879e6029d14ec2f655\",\"name\":\"StepByStepSchoolsSupport\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.stepbystepschools.net\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cecaf2a0ee369391127b0159c266979d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cecaf2a0ee369391127b0159c266979d?s=96&d=mm&r=g\",\"caption\":\"StepByStepSchoolsSupport\"},\"url\":\"https:\/\/www.stepbystepschools.net\/?author=40\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"ASP.NET MVC Queries \u2013 Part 1. - Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.stepbystepschools.net\/?p=1673","og_locale":"en_US","og_type":"article","og_title":"ASP.NET MVC Queries \u2013 Part 1. - Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai","og_description":"This query was asked by one of students who had attended MVC training in Mumbai past week. Below are the questions and answers , can be useful for some students. In lab 3 the one with View data-U mentioned we &hellip; Continue reading &rarr;","og_url":"https:\/\/www.stepbystepschools.net\/?p=1673","og_site_name":"Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai","article_published_time":"2017-07-21T08:48:07+00:00","twitter_card":"summary_large_image","twitter_misc":{"Written by":"StepByStepSchoolsSupport","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/www.stepbystepschools.net\/#website","url":"https:\/\/www.stepbystepschools.net\/","name":"Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai","description":"MVC 5\/Core, AngularJS 1.x, 2.0, 4.0, Design Pattern, Architecture, SSIS, SSAS, SSRS, Data Science, Big data, Hadoop classroom training","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.stepbystepschools.net\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.stepbystepschools.net\/?p=1673#webpage","url":"https:\/\/www.stepbystepschools.net\/?p=1673","name":"ASP.NET MVC Queries \u2013 Part 1. - Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai","isPartOf":{"@id":"https:\/\/www.stepbystepschools.net\/#website"},"datePublished":"2017-07-21T08:48:07+00:00","dateModified":"2017-07-21T08:48:07+00:00","author":{"@id":"https:\/\/www.stepbystepschools.net\/#\/schema\/person\/7131e4ee1c5673879e6029d14ec2f655"},"breadcrumb":{"@id":"https:\/\/www.stepbystepschools.net\/?p=1673#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.stepbystepschools.net\/?p=1673"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.stepbystepschools.net\/?p=1673#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.stepbystepschools.net\/"},{"@type":"ListItem","position":2,"name":"ASP.NET MVC Queries \u2013 Part 1."}]},{"@type":"Person","@id":"https:\/\/www.stepbystepschools.net\/#\/schema\/person\/7131e4ee1c5673879e6029d14ec2f655","name":"StepByStepSchoolsSupport","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.stepbystepschools.net\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cecaf2a0ee369391127b0159c266979d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cecaf2a0ee369391127b0159c266979d?s=96&d=mm&r=g","caption":"StepByStepSchoolsSupport"},"url":"https:\/\/www.stepbystepschools.net\/?author=40"}]}},"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"_links":{"self":[{"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=\/wp\/v2\/posts\/1673"}],"collection":[{"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=\/wp\/v2\/users\/40"}],"replies":[{"embeddable":true,"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1673"}],"version-history":[{"count":5,"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=\/wp\/v2\/posts\/1673\/revisions"}],"predecessor-version":[{"id":1678,"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=\/wp\/v2\/posts\/1673\/revisions\/1678"}],"wp:attachment":[{"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1673"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1673"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}