MVC Web Authoring

Source: Internet
Author: User
Tags actionlink

(1) First, a Web page is divided into four small pieces, one by one to do

(a) First click the View Right button to add views, set a main display page.

@{Layout=NULL;}<! DOCTYPE html>"Viewport"Content="Width=device-width"/> <title>index</title> <style type="Text/css">#q {}</style><table width= "100%" border= "0" cellpadding= "0" cellspacing= "0" > <tr> <td id= "Q" width= "1           00% "align=" center "bgcolor=" #FFBBFF "> Zibo Han Enterprise Training and Education Center </td> </tr> </table><table width= "100%" border= "0" cellpadding= "0" cellspacing= "0" > <tr> <td align= "center" h Eight= "> @Html. Partial (" ~/views/zuobian.cshtml ") </td> <td align=" center "Hei Ght= "> @RenderBody () </td> </tr> </table><table width= "100%" border= "0" cellpadding= "0" cellspacing= "0" > <tr> <td align= "center" width = "100%" height= "> Zibo Han Enterprise Talent Customization Center <br/>2007~2015</td> </tr></table></body>
(b) The middle row is divided into two columns and the left side is displayed:


★ Create a view when you want to click Create as a partial view.
   operating keys for ☆controller
UsingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;usingSYSTEM.WEB.MVC;usingstencil making. Models;namespacestencil making. controllers{ Public classHomecontroller:controller {// //GET:/home/ PublicActionResult Index () {returnView (); } Public actionresult ShowDetails (int id) {New data = new NEWSBF (). Selectbykey (ID);//Click on the news on the right to insert the database content function return View (data); } Public ActionResult shownewsindexpartial (string newType)//function {viewbag.data = new NEWSBF to the right of the Display page database ( ). Select (NewType); return Partialview (); } Public ActionResult Guonei ()//define a domestic function {return View (); } public ActionResult Guoji ()//define the International function {return View (); } public ActionResult Yule ()//function defining Entertainment {return View (); } public ActionResult Caijing ()//define Finance function {return View (); } }}
      ; Layout  =  ~/views/zong.cshtml  Span style= "color: #800000;" > " ;} @{ null    
          else   { <div> no related data found </div > 
   as  List<new>;  <ul> @foreach (New data  in   list) { <li> @Html. ActionLink (Data.title,   " showdetails  " ,  " home  " ,  {id=data.ids}, null  );  </li> </ul 
   {3 "Add view for domestic news   
@{ Viewbag.title = guonei " ; Layout = ~/views/zong.cshtml Span style= "color: #800000;" > " ; } @Html. Action ( " shownewsindexpartial , new {newtype= " 0 })
    guoji   " ; Layout  =  ~/views/zong.cshtml  Span style= "color: #800000;"        > " ; }   @Html. Action (  " shownewsindexpartial  , new  {newtype=  " 1  }) 
    yule   " ; Layout  =  ~/views/zong.cshtml  Span style= "color: #800000;"        > " ;   @Html. Action (  " shownewsindexpartial  , new  {newtype=  " 2  }) 
{6} Added view of financial news
@{ "caijing"; " ~/views/zong.cshtml " ; } @Html. Action ("shownewsindexpartial" New {newtype="3"})
  (iii) methods of operation of the database
UsingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;namespacestencil making. models{ Public classNEWSBF {PrivateMydbdatacontext _context =NewMydbdatacontext (); PublicList<new> Select (stringtype) { return_context.new.where (p = P.type = =type). ToList (); } PublicNew Selectbykey (intID) {varquery = _context.new.where (p = = P.ids = =ID); if(Query. Count () >0) { returnquery. First (); } return NULL; } }}

(d) The picture can be put down directly in the view to add a picture of the folder, and then directly drag the picture in use.

MVC Web Authoring

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.