精华内容
下载资源
问答
  • The partial sum problem

    2017-08-28 09:13:28
    The partial sum problem 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述One day,Tom’s girlfriend give him an array A which contains N integers and asked him:Can you choose some ...

    The partial sum problem

    时间限制: 1000 ms  |  内存限制: 65535 KB
    难度: 2
    描述
    One day,Tom’s girlfriend give him an array A which contains N integers and asked him:Can you choose some integers from the N integers and the sum of them is equal to K. 
    输入
    There are multiple test cases.
    Each test case contains three lines.The first line is an integer N(1≤N≤20),represents the array contains N integers. The second line contains N integers,the ith integer represents A[i](-10^8≤A[i]≤10^8).The third line contains an integer K(-10^8≤K≤10^8).
    输出
    If Tom can choose some integers from the array and their them is K,printf ”Of course,I can!”; other printf ”Sorry,I can’t!”.
    样例输入
    4
    1 2 4 7
    13
    4
    1 2 4 7
    15
    样例输出
    Of course,I can!
    Sorry,I can't!

    import java.util.Scanner;
    
    public class Main {
    
    	static int number, sum;
    	static int arr[] = new int[25];
    	static int vis[] = new int[25];
    
    	public static boolean dfs(int step, int count) {
    		if (step == number) {
    			return count == sum;
    		}
    		vis[step] = 1;
    		if (dfs(step + 1, count + arr[step])) {
    			return true;
    		}
    		vis[step] = 0;
    		if (dfs(step + 1, count)) {
    			return true;
    		}
    		return false;
    	}
    
    	public static void main(String[] args) {
    		Scanner scanner = new Scanner(System.in);
    		while (scanner.hasNext()) {
    			number = scanner.nextInt();
    			for (int i = 0; i < number; i++) {
    				arr[i] = scanner.nextInt();
    			}
    			sum = scanner.nextInt();
    			if (dfs(0, 0)) {
    				System.out.println("Of course,I can!");
    			} else {
    				System.out.println("Sorry,I can't!");
    			}
    		}
    	}
    
    }
    


    展开全文
  • Partial函数的定义 scala> val isVeryTasty: PartialFunction[String, String] = { case "Glazed Donut" | "Strawberry Donut" => "Very Tasty"}isVeryTasty: PartialFunction[String,String] = <function...

    Partial函数的定义

    scala> val isVeryTasty: PartialFunction[String, String] = { case "Glazed Donut" | "Strawberry Donut" => "Very Tasty"}
    isVeryTasty: PartialFunction[String,String] = <function1>

    scala> isVeryTasty("Glazed Donut")
    res3: String = Very Tasty

     

    Partianl函数的组合使用:

     

    code :

     

      println("\nStep 1: How to define a Partial Function named isVeryTasty")
      val isVeryTasty: PartialFunction[String, String] = { case "Glazed Donut" | "Strawberry Donut" => "Very Tasty"}
    
    
    
      println("\nStep 2: How to call the Partial Function named isVeryTasty")
      println(s"Calling partial function isVeryTasty = ${isVeryTasty("Glazed Donut")}")
      // NOTE: you will get scala.MatchError
    
    
    
      println("\nStep 3: How to define PartialFunction named isTasty and unknownTaste")
      val isTasty: PartialFunction[String, String] = {
        case "Plain Donut" => "Tasty"
      }
    
      val unknownTaste: PartialFunction[String, String] = {
        case donut @ _ => s"Unknown taste for donut = $donut"
      }
    
    
    
      println("\nStep 4: How to compose PartialFunction using orElse")
      val donutTaste = isVeryTasty orElse isTasty orElse unknownTaste
      println(donutTaste("Glazed Donut"))
      println(donutTaste("Plain Donut"))
      println(donutTaste("Chocolate Donut"))

    result:

    Step 1: How to define a Partial Function named isVeryTasty
    
    Step 2: How to call the Partial Function named isVeryTasty
    Calling partial function isVeryTasty = Very Tasty
    
    Step 3: How to define PartialFunction named isTasty and unknownTaste
    
    Step 4: How to compose PartialFunction using orElse
    Very Tasty
    Tasty
    Unknown taste for donut = Chocolate Donut

     

    转载于:https://www.cnblogs.com/lianghong881018/p/11174823.html

    展开全文
  • Define a KFF step by step

    千次阅读 2012-05-04 18:40:01
    Define a KFF step by step Author: Pan Tian Creation Date: 04/05/2012 Last Updated:  Version:  Status:


    Define a KFF step by step



    Author:                         Pan Tian
    Creation Date:            04/05/2012
    Last Updated:             
    Version:                        
    Status:                           


    Contents

    Define a KFF step by step                                                                                                                                                                              1
    BaseTable表增加一个外键列                                                                                                                                                              1
    Block中创建一个Flexfield的隐藏item                                                                                                                                              1
    Block中创建一个Flexfield显示字段                                                                                                                                                 1
     
                                                                                                                                                                                                                                 2
    When-New-Form-Instance中加入FlexField的定义                                                                                                                        2
    Trigger中调用FlexField标准的方法                                                                                                                                                  3
    Flexfield相关的API                                                                                                                                                                                     4
    FlexField的相关表                                                                                                                                                                                      8
     
     

    Define a KFF step by step

    BaseTable 表增加一个外键列

    Base Table 中定义一个字段 XXX_ID ,这个用于保存 KFF表记录的主键(对于 Base Table 就是外键列),比如对于本例,如果要增加一个 Account KFF ,需要在 Base Table 上增加一个 XXX_ID外键字段用于保存捕获的 CODE_COMBINATION_ID

    Block 中创建一个 Flexfield的隐藏 item

    Block中定义一个隐藏字段用于保存上边一步创建的 FK 字段,设置 canvas NULL TEXT_ITEM property class



    Block 中创建一个 Flexfield显示字段

    创建了隐藏字段,当然要创建一个显示的字段让用户来输入,这里我们需要创建一个 non-database 字段用来展示合并的科目值, subclass Information 继续使用TEXT_ITEM, 设置合适 canvas 来显示,LOV 设置为 'ENABLE_LIST_LAMP' 'Validate from list' is set to No

                                                     

    When-New-Form-Instance 中加入FlexField 的定义

    When-New-Form-Instance 中加入 FlexField的定义,当然好的戏,代码类似于

            

     SELECT CHART_OF_ACCOUNTS_ID INTO :PARAMETER.CHART_OF_ACCOUNTS_ID
    
             FROM ORG_ORGANIZATION_DEFINITIONS
    
             WHERE ORGANIZATION_ID = :PARAMETER.ORG_ID;
    
             FND_KEY_FLEX.DEFINE(
    
             BLOCK => 'TOMAI_MAIN_HEADER_BLK',
    
              FIELD => 'TO_ACCOUNT_PT',
    
              CODE => 'GL#',
    
              APPL_SHORT_NAME =>'SQLGL',
    
              NUM => ':PARAMETER.CHART_OF_ACCOUNTS_ID',
    
              ID => 'TO_ACCOUNT_PT_id',
    
              VRULE => '\\nSUMMARY_FLAG\\nI\\nAPPL=SQLGL;NAME=GL_NO_PARENT_SEGMENT_ALLOWED\\nN\\0GL_GLOBAL\\nDETAIL_POSTING_ALLOWED\\nE\\nAPPL=INV;NAME=INV_VRULE_POSTING\\nN',
    
               REQUIRED => 'N',
    
               DINSERT  => 'Y',
    
              VALIDATE => 'FULL',
    
              USEDBFLDS => 'N');

    FND_KEY_FLEX.DEFINE 的用法

    FND_KEY_FLEX.DEFINE( 
    block => 'Custom block',
    Field => 'BTL_KFF',-- 第三步创建的显示 item
    ID => 'XXX_ID',-- 第二步创建的隐藏 item
    Appl_short_name => 'SQLGL',
    Code => 'GL#',--ID_FLEX_CODE 
    Num => '101',--Chart of account
    Vrule => 'GL_GLOBAL\nDETAIL_POSTING_ALLOWED \nE\nAPPL=''SQLGL'';
    name=Parent Values are not allowed\nN'
    );


    Trigger 中调用FlexField 标准的方法

    Trigger包括

        PRE-QUERY

        POST-QUERY

        PRE-INSERT

        PRE-UPDATE

        WHEN-VALIDATE-RECORD

        WHEN-NEW-ITEM-INSTANCE

    WHEN-VALIDATE-ITEM

    代码类似于:

    WHEN-VALIDATE-ITEM
        if ( :system.mode = 'NORMAL' ) then
           fnd_flex.event( 'WHEN-VALIDATE-ITEM' );
        end if;
    WHEN-NEW-ITEM-INSTANCE
        app_standard.event('WHEN-NEW-ITEM-INSTANCE');
        fnd_flex.event('WHEN-NEW-ITEM-INSTANCE' );
    POST-QUERY
    --Loads the flexfields (in our case, it populates
    --the concatenated field on execute query).
        FND_FLEX.EVENT('POST-QUERY');
    PRE-QUERY
    --If you don't do this, whatever query criteria you may enter in
    -- the concatenated flex field, it is not taken into account.
        FND_FLEX.EVENT('PRE-QUERY' );
    KEY-LISTVAL
        APP_STANDARD.EVENT('KEY-LISTVAL');
        FND_FLEX.EVENT('KEY-LISTVAL' );

    一般情况下,我们会把 fnd_flex.event这样的代码放在 Form 级别,这样我们新加的 Trigger只要不是 Override 模式, 那么 fnd_flex.event都会被执行到,当然如果你的 trigger override 模式或者需要比较复杂的 Flexfield 的业务逻辑,那么你就必须手工添加 fnd_flex.event 代码到你的 Trigger中。对于本例 Account KFF 来说,因为要校验 Account ID 是否有效,所以需要在 When-Validate-Item中加入一些其他校验

       FND_FLEX.EVENT('WHEN-VALIDATE-ITEM');
    
        IF :BLOCK.XXX_ID = -1 THEN
    
        FND_MESSAGE.SET_STRING('You Have Selected An Undefined Code Combination !');
    
        FND_MESSAGE.SHOW;
    
        RAISE FORM_TRIGGER_FAILURE;
    
    END IF;

    Flexfield 相关的API

    FND_KEY_FLEX.DEFINE in Developer Guide
    Use FND_KEY_FLEX.DEFINE for a key flexfield on a foreign key or combinations form.
    Attention: We provide combinations form syntax so you can
    convert any existing non–Oracle Applications combinations
    forms you may have from SQL*Forms 2.3 to Oracle Forms 4.5.
    However, the API for key flexfields may change in future
    versions of Oracle Applications, so we recommend that you do
    not create any new key flexfields that are not provided by
    Oracle Applications.
    FND_KEY_FLEX.DEFINE(
    /* Arguments that specify flexfield location */
    BLOCK=>’block_name’,
    FIELD=>’concatenated_segments_field_name’,
    [DESCRIPTION=>’description_field_name’,]
    [ID=>’Unique_ID_field’,]
    [DATA_FIELD=>’concatenated_hidden_IDs_field’,]
    /* Arguments that specify the flexfield */
    APPL_SHORT_NAME=>’application_short_name’,
    CODE=>’key_flexfield_code’,
    NUM=>’structure_number’,
    /* Other optional parameters */
    [VALIDATE=>’{FOR_INSERT|FULL|PARTIAL|NONE|
    PARTIAL_IF_POSSIBLE}’,]
    [VDATE=>’date’,]
    [DISPLAYABLE=>’{ALL | flexfield_qualifier |
    segment_number}[\\0{ALL |
    flexfield_qualifier | segment_number}]’,]
    [INSERTABLE=>’{ALL | flexfield_qualifier |
    segment_number}[\\0{ALL |
    flexfield_qualifier | segment_number}]’,]
    [UPDATEABLE=>’{ALL | flexfield_qualifier |
    segment_number}[\\0{ALL |
    flexfield_qualifier | segment_number}]’,]
    [VRULE=>’flexfield qualifier\\n
    segment qualifier\\n
    {I[nclude]|E[xclude]}\\n
    APPL=application_short_name;
    NAME=Message Dictionary message name\\n
    validation value1\\n
    validation value2...
    [\\0flexfield qualifier\\n
    segment qualifier\\n
    {I[nclude]|E[xclude]}\\n
    APPL=application_short_name;
    NAME=Message Dictionary message name\\n
    validation value1\\n
    validation value2...]’,]
    [COPY=>’block.field\\n{ALL | flexfield
    qualifier | segment_number}
    [\\0block.field\\n{ALL | flexfield
    qualifier | segment_number}]’,]
    [DERIVED=>’block.field\\nSegment qualifier’,]
    [DERIVE_ALWAYS=>’{Y|N}’,]
    [DINSERT=>’{Y|N}’,]
    [VALATT=>’block.field\\n
    flexfield qualifier\\n
    segment qualifier’,]
    [TITLE =>’Title’,]
    [REQUIRED=>’{Y|N}’,]
    [AUTOPICK=>’{Y|N}’,]
    [USEDBFLDS=>’{Y|N}’,]
    [ALLOWNULLS=>’{Y|N}’,]
    [DATA_SET=>’set number’,]
    [COLUMN=>’{column1(n) | column1 alias(n)
    [, column2(n), ...] [INTO block.field]}’,]
    [WHERE_CLAUSE=>’where clause’,]
    [COMBQP_WHERE=>’{where clause|NONE}’,]
    [WHERE_CLAUSE_MSG=>’APPL=application_short_
    name;NAME=message_name’,]
    [QUERY_SECURITY=>’{Y|N|}’,]
    [QBE_IN=>’{Y|N}’,]
    [READ_ONLY=>’{Y|N}’,]
    [LONGLIST=>’{Y|N}’,]
    [NO_COMBMSG=>’APPL=application_short_
    name;NAME=message_name’,]
    [AUTOCOMBPICK=>’{Y|N}’,]
    [LOCK_FLAG=>’{Y|N}’,]
    [HELP=>’APPL=application_short_name;
    TARGET=target_name’]
    );
    You should not use a colon ( : ) in block.field references for the
    VALATT, COPY, or DERIVED arguments. The arguments for these
    routines go to an Oracle Application Object Library cover routine and
    are not directly interpreted in PL/SQL.

    fnd_flex.event

    fnd_flex.event的代码位于 FNDSQF.pll

      procedure event(event_name varchar2) is
    
      begin
    
        fnd_flex_private.flex_debug('BEGIN FND_FLEX.EVENT('||event_name||')');
    
        if ((event_name = 'WHEN-VALIDATE-ITEM') AND
    
            (name_in('system.mode') = 'ENTER-QUERY')) then
    
           GOTO lbl_return;
    
        end if;
    
        --
    
        -- Synchronize call seems to solve some problems in
    
        -- event handling in Forms side.
    
        -- According to Peter this call does nothing, but let's
    
        -- call it. G.Olgun
    
        --
    
        -- Per Peter's request commenting out the code.
    
        --
    
        --IF (event_name = 'WHEN-NEW-ITEM-INSTANCE') THEN
    
        --   synchronize;
    
        --END IF;
    
        --
    
        user_exit('FND FFLEX ' || event_name);
    
        if (NOT Form_Success) then
    
           fnd_flex_private.flex_failure('user_exit(FND FFLEX ' ||
    
                                              event_name || ') is failed.');
    
           copy(NULL, 'GLOBAL.FND_FLEX_NAVIGATE');
    
           copy(NULL, 'GLOBAL.FND_FLEX_NAVIGATE_PUBLIC');
    
           copy(NULL, 'GLOBAL.FND_FLEX_READONLY');
    
           copy(NULL, 'GLOBAL.FND_FLEX_ENABLELOV');
    
           raise FORM_TRIGGER_FAILURE;
    
        end if;
    
        -- if (event_name = 'POST-QUERY') then
    
        --   set_record_property(name_in('SYSTEM.TRIGGER_RECORD'),
    
        --                     name_in('SYSTEM.TRIGGER_BLOCK'),
    
        --                     STATUS, QUERY_STATUS);
    
        -- end if;
    
        fnd_flex_private.navigate_from_flex;
    
        if (event_name = 'WHEN-NEW-ITEM-INSTANCE') then
    
          fnd_flex_private.set_flex_item_properties;
    
        end if;
    
        --
    
        -- This step was asked for by Peter Wallack to enable localizations
    
        -- This would eventually be moved to APPCORE.
    
        --
    
        if (event_name = 'WHEN-VALIDATE-RECORD') then
    
          copy('Y', 'GLOBAL.APPCORE_WVR_ZOOM');
    
          execute_trigger('ZOOM');
    
          if not form_success then
    
            raise form_trigger_failure;
    
           end if;
    
        end if;
    
        <<lbl_return>>
    
          fnd_flex_private.flex_debug('END FND_FLEX.EVENT('||event_name||')');
    
          RETURN;
    
      EXCEPTION
    
         WHEN OTHERS THEN
    
             fnd_flex_private.flex_exception('FND_FLEX.EVENT');
    
             RAISE;
    
      end event;


    FlexField 的相关表

    FND_ID_FLEXS:

    This table captures the information of all the Key FlexFields. The main columns in this table are:

        APPLICATION_ID  Column consists of Application ID

        ID_FLEX_CODE  Column KFF Code (like  GL# AR#  etc.)

        ID_FLEX_NAME  -  KFF Name (like ‘Accounting Flexfield’, ‘Category Flexfield’..etc.)

        APPLICATION_TABLE_NAME – Name of combination table (like ‘GL_CODE_COMBINATIONS’ , ‘FA_LOCATIONS’ etc.)

    FND_ID_FLEX_STRUCTURES:

    This table stores structure information about key Flexfields. Each Structure is uniquely identified by

        APPLICATION_ID – Module Code

        ID_FLEX_CODE  – Code of KFF

        ID_FLEX_NUM – Number of a Structure

    FND_ID_FLEX_SEGMENTS:

    It captures the information of Segments. Each Segment is Uniquely identified by

        APPLICATION_ID – Module Code

        ID_FLEX_CODE – Key Flexfield code

        ID_FLEX_NUM – Key flexfield structure number

        SEG_NUM – Segment number

        FLEX_VALUE_SET_ID – Flexfield value set identifier

    FND_FLEX_VALUE_SETS:

    This table captures the information of each Segment’s Value Set. Each Value Set is Uniquely identified by FLEX_VALUE_SET_ID as Foreign Key of FND_ID_FLEX_SEGMENTS Table.

    FND_FLEX_VALUES:

    This table captures the information each Value codes of a Value Set of a Segment. Each Value Code is uniquely identified by

        FLEX_VALUE_SET_ID

        FLEX_VALUE_ID

    FND_FLEX_VALUES_TL:

    This table captures the information of each Value Description of a Value Set of a Segment. Each Value Description is uniquely identified by FLEX_VALUE_ID.

     

    转载请注明出处: http://blog.csdn.net/pan_tian/article/details/7535842
    展开全文
  • MVC之Partial View 用法

    千次阅读 2018-01-01 16:57:19
    Partial View 顾名思义就是Html...Partial View 需要放在Views/Shared 目录下,任何Controlller 下的Action 或 View 都可以载入。 如何载入Partial View? MVC 的 HTML 辅助方法有个专门的方法载入分部View,方法名称为

    Partial View 顾名思义就是Html代码片段,因此可以用Partial View 把部分的Html或显示逻辑包装起来,方便多次使用。

    Partial View 需要放在Views/Shared 目录下,任何Controlller 下的ActionView 都可以载入。

    如何载入Partial View?

    MVC 的 HTML 辅助方法有个专门的方法载入分部View,方法名称为Partial.

    Partial有以下四种方式调用

    方法原型使用范例
    Partial(HtmlHelper,String)Html.Partial("CustomerListControl")
    Partial(HtmlHelper,string,Object)Html.Partial("CustomerListControl",Model)
    Partial(HtmlHelper,string,ViewDataDictionary)Html.Partial("CustomerListControl",ViewData["Model"])
    Partial(HtmlHelper,string,Object,ViewDataDictionary)Html.Partial("CustomerListControl",Model,ViewData["Model"])

    使用控制器载入分部View

    public ActionResult  CustomerListControl()
    {
       Return PartialView();
    }

    使用 Html.Action 载入分部View

    @Html.Action("CustomerListControl")

    如何实现?

    1 Models

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    
    namespace Step1.Models
    {
        public class Product
        {
            public string Name
            {
                get;
                set;
            }
    
            public string Banner
            {
                get;
                set;
            }
        }
    }
    
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    namespace Step1.Models
    {
        public class OrderModel
        {
            public Customer Customer
            {
                get;
                set;
            }
            public List<Product> ProductList
            {
                get;
                set;
            }
        }
    }

    2 DAL

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Step1.DAL;
    using Step1.Models;
    namespace Step1.DAL
    {
        public class DBContext
        {
            public static OrderModel GetOrderList()
            {
                OrderModel model = new OrderModel();
                model.Customer = new Customer() { CustomerID = "10000", CompanyName = "redwave" };
                model.ProductList = new List<Product>();
                for (int i = 0; i < 10; i++)
                {
                    Product p = new Product();
                    p.Banner = string.Format("Banner{0}", i.ToString());
                    p.Name = string.Format("ProductMame{0}", i.ToString());
                    model.ProductList.Add(p);
                }
                return model;
            }
        }
    }

    3 Controller

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using Step1.DAL;
    namespace Step1.Controllers
    {
        public class PartialViewController : Controller
        {
            //
            // GET: /PartialView/
    
            public ActionResult Index()
            {
                var model=   DBContext.GetOrderList();
    
                return View(model);
            }
    
        }
    }

    4 Partial View

    @using Step1.Models;
    @using System.Collections;
    @model IEnumerable<Product>
    <table border="1" >
        <tr >
            <td>
                Name
            </td>
            <td>
                Banner
            </td>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @item.Name
                </td>
                <td>
                    @item.Banner
                </td>
            </tr>
        }
    
    </table>

    5 View

    using Step1.Models;
    @model OrderModel
    @{
        ViewBag.Title = "Index";
    }
    
    <h2>Index</h2>
    <div>
        <div>
            @Model.Customer.CompanyName
        </div>
        <div>
            @Model.Customer.CustomerID
        </div>
        <div>
            @Html.Partial("CustomerListControl",@Model.ProductList)
        </div>
    </div>

    6 项目结构

    这里写图片描述

    7 运行结果

    这里写图片描述


    MVC |分部视图 PartialView()

    介绍如何定义

    其实它和普通视图没有多大区别,只是创建分部视图的时候视图里没有任何内容,你需要什么标签你自己加。第二就是分部视图不会执行_ViewStart.cshtml中的内容)

    控制器

    PartialViewDeomController控制器

        using System;  
        using System.Collections.Generic;  
        using System.Linq;  
        using System.Web;  
        using System.Web.Mvc;  
    
        namespace MvcApp.Controllers  
        {  
            public class PartialViewDeomController : Controller  
            {  
                //  
                // 分部视图的作用一般用于嵌到如一些正常的视图中去。(类似与自定义控件)相当于: Server.Execute(string path)  
    
                public ActionResult PartialIndex()  
                {  
                    //View()方法返回的视图默认都会去执行_ViewStart.cshtml中的内容  
                    //return View();  
    
                    //分部视图不会去执行_ViewStart.cshtml中的内容(分部视图以PartialView()返回)  
                    return PartialView();  
                }  
            }  
        }  

    PartialIndex 视图

        <!--注意,创建分部视图后,视图里是没有任何东西的。自己需要什么标签,就加什么标签。这个视图的用法就是到时候嵌套到一些以View()返回的正常视图中去-->  
    
        <select id="dp1">  
            <option value="0">湖南</option>  
            <option value="1">广东</option>  
            <option value="0">上海</option>>  
        </select>  
    
        <select id="dp2">  
            <option value="0">纽约</option>  
            <option value="1">洛杉矶</option>  
            <option value="0">华盛顿</option>>  
        </select>  

    这里写图片描述

    使用介绍(我们发现它与普通视图是差不多的)

    PartialViewDeomController控制器

        using System;  
        using System.Collections.Generic;  
        using System.Linq;  
        using System.Web;  
        using System.Web.Mvc;  
    
        namespace MvcApp.Controllers  
        {  
            using MvcApp.Models;  
            public class PartialViewDeomController : Controller  
            {  
                //  
                // 分部视图的作用一般用于嵌到如一些正常的视图中去。(类似与自定义控件)相当于: Server.Execute(string path)  
    
                public ActionResult PartialIndex()  
                {  
    
                    var list = new List<T_UserInfo>()  
                    {  
                        new T_UserInfo(){Id=1,UserName="无盐海",Name="凡斌"},  
                        new T_UserInfo(){Id=1,UserName="阿宝",Name="周晶"},                           
                    };  
    
                    //分部视图不会去执行_ViewStart.cshtml中的内容(分部视图以PartialView()返回)  
                    return PartialView(list);  
                }  
            }  
        }  

    PartialIndex视图

        @model List<MvcApp.Models.T_UserInfo>  
    
        <select id="dp1">  
            @{  
                foreach (var item in Model)   
                {   
                     <option value="0">@item.Name</option>  
                }  
            }  
        </select>  

    真实的使用介绍 (重点)

    PartialViewDeomController控制器

        using System;  
        using System.Collections.Generic;  
        using System.Linq;  
        using System.Web;  
        using System.Web.Mvc;  
    
        namespace MvcApp.Controllers  
        {  
            using MvcApp.Models;  
            public class PartialViewDeomController : Controller  
            {  
                public ActionResult Index()  
                {  
                    return View();  
                }  
    
                // 分部视图的作用一般用于嵌到如一些正常的视图中去。(类似与自定义控件)相当于: Server.Execute(string path)  
    
                public ActionResult PartialIndex()  
                {  
    
                    var list = new List<T_UserInfo>()  
                    {  
                        new T_UserInfo(){Id=1,UserName="无盐海",Name="凡斌"},  
                        new T_UserInfo(){Id=1,UserName="阿宝",Name="黄雪辉"},                           
                    };  
    
                    //分部视图不会去执行_ViewStart.cshtml中的内容(分部视图以PartialView()返回)  
                    return PartialView(list);  
                }  
            }  
        }  

    Index视图与PartialIndex分部视图。(注意:这里是在Index视图里调用PartialIndex分部视图)

        @{  
            Layout = null;  
        }  
        @using MvcApp.Models;  
        <!DOCTYPE html>  
    
        <html>  
        <head>  
            <meta name="viewport" content="width=device-width" />  
            <title>Index</title>  
            <script src="~/Scripts/jquery-1.8.2.js"></script>  
        </head>  
        <body>  
            <div id="loadData"></div>  
    
            <div>  
                <!--第一种方式:同一控制起下调用分部视图-->  
                @Html.Partial("PartialIndex", new List<T_UserInfo>() { new T_UserInfo() { Id = 1, UserName = "无盐海", Name = "凡斌" }, new T_UserInfo() { Id = 1, UserName = "阿宝", Name = "周晶" }, })  
    
                <!--第二种方式:同一控制起下调用分部视图-->  
                @{  
                    Html.RenderPartial("PartialIndex", new List<T_UserInfo>() { new T_UserInfo() { Id = 1, UserName = "无盐海", Name = "凡斌" }, new T_UserInfo() { Id = 1, UserName = "阿宝", Name = "周晶" } });  
                }  
    
                <!--第三种方式:可以跨控制器调用分部视图(注意:如果通过这种方式调用分部视图,如果在再PartialIndex这个action中有传参给分部视图,则在此处调用就不需要再传递参数了)-->  
                @{Html.RenderAction("PartialIndex", "PartialViewDeom");}  
    
                <!--第四种方式:也是可以跨控制器调用分部视图。和第三种是一样的-->  
                @Html.Action("PartialIndex", new { controller = "PartialViewDeom" })  
    
                <!--第五种方式:用ajax来调用:如:jquery的Load()方法-->  
                <script type="text/javascript">  
                    $(function () {  
                        $("#loadData").load("/PartialViewDeom/PartialIndex"); //将PartialIndex分部视图中的内容加载到id为loadData这个元素中去  
                    })  
                </script>  
            </div>action  
        </body>  
        </html>  

    这里写图片描述

    展开全文
  • MVC 之 Partial View 用法

    2017-11-16 14:34:00
    Partial View 顾名思义就是Html代码片段,因此可以用Partial View 把...Partial View 需要放在Views/Shared 目录下,任何Controlller 下的Action 或 View 都可以载入。 如何载入Partial View? MVC 的 HTML 辅助方法...
  • Scala教程之:PartialFunction

    千次阅读 2020-01-06 09:53:53
    Scala中有一个很有用的traits叫PartialFunction,我看了下别人的翻译叫做偏函数,但是我觉得部分函数更加确切。 那么PartialFunction是做什么用的呢?简单点说PartialFunction用在模式匹配中,是一个不完整的函数,...
  • Point pattern matching is an essential step in many image processing applications. This letter investigates the spectral approaches of point pattern matching, and presents a spectral feature matching ...
  • Partial wake locks are a mechanism in thePowerManagerAPI that lets developers keep the CPU running after a device's display turns off (whether due to system timeout or the user pressing the power bu.....
  • You've got an arraya, consisting ofnintegers. The array elements are indexed from 1 ton. Let's determine a two step operation like that: ...First we build by the arrayaan arraysof partial sums, ...
  • MVC Razor and partial view

    千次阅读 2013-08-26 04:13:53
    How do I use a partial view in MVC 3? Great!! Sometime, I don't know why, I stuck for small things. I was trying to load two partial views(MVC 3). But, after spending 6 hours I got to know how to...
  • This is my controller action [AcceptVerbs(HttpVerbs.Post)] public ActionResult UpdateStep2(FormCollection form) { var factory = SessionFactoryCreator.Create(); using (var session = factory....
  • PartialView的用法

    千次阅读 2018-07-06 14:49:51
    Partial View 需要放在Views/Shared 目录下,任何Controlller 下的Action 或 View 都可以载入。   如何载入Partial View? MVC 的 HTML 辅助方法有个专门的方法载入分部View,方法名称为Partial.  Partial有以下四种...
  • Building your Recurrent Neural Network - Step by Step Welcome to Course 5’s first assignment! In this assignment, you will implement your first Recurrent Neural Network in numpy. Recurrent Neural ...
  • subversion on Mac OS X step by step

    千次阅读 2009-09-02 00:07:00
    A subversion/notes/commit-access-templates/partial-committer.tmpl A subversion/notes/commit-access-templates/contrib-committer.tmpl A subversion/notes/commit-access-templates/full-committer....
  • 1. MDX Step by Step 读书笔记(三) - Understanding Tuples (理解元组) 理解 Member 成员 和 Tuple 元组的概念 理解属性层次结构和轴 理解 Cell 单元格 理解局部元组 Partial Tuple 和 SSAS如何处理局部元组 ...
  • DFS-The partial sum problem

    2016-04-02 13:00:50
    The partial sum problem 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述One day,Tom’s girlfriend give him an array A which contains N integers and asked him:Can you choose some ...
  • 卷积神经网络Step by Step(四)

    千次阅读 2017-06-15 11:28:08
    卷积神经网络Step by Step(四) 系列的第一篇博客对卷积神经网络的几个重要概念进行总结,现在就从代码的角度对”卷积”,”池化”,”反向传播”进行详细的分析。 代码是基于“UFLDL Tutorial”的excercise代码...
  • Building your Recurrent Neural Network - Step by Step Welcome to Course 5’s first assignment! In this assignment, you will implement your first Recurrent Neural Network in numpy. Recurrent Neural ...
  • Let A=(a[i][j]) be an n*n matrix. Step 1. Read the matrix
  • HOG/svm Step by Step

    千次阅读 2016-08-23 10:15:54
    TermCriteria — Termination criteria of the iterative SVM training procedure which solves a partial case of constrained quadratic optimization problem. You can specify tolerance and/or the maximum ...
  • Partial Least Square (PLS) has been shown to be a robust method for describing the relationship between signal changes in brain and a set of exogenous variables (i.e. task demands, performance, or ...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 15,253
精华内容 6,101
关键字:

partialstep