第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Html.Partial對(duì)Html.RenderPartial&Html.Action對(duì)Html

Html.Partial對(duì)Html.RenderPartial&Html.Action對(duì)Html

慕田峪4524236 2019-06-20 16:05:58
Html.Partial對(duì)Html.RenderPartial&Html.Action對(duì)Html在ASP.NETMVC中,在以下方面有什么區(qū)別:Html.Partial和Html.RenderPartialHtml.Action和Html.RenderAction
查看完整描述

3 回答

?
米琪卡哇伊

TA貢獻(xiàn)1998條經(jīng)驗(yàn) 獲得超6個(gè)贊

Html.Partial返回一個(gè)字符串。Html.RenderPartial打電話Write內(nèi)部和返回void.

基本用法是:

// Razor syntax@Html.Partial("ViewName")@{ Html.RenderPartial("ViewName");  }
// WebView syntax<%: Html.Partial("ViewName") %><% Html.RenderPartial("ViewName"); %>

在上面的片段中,兩個(gè)調(diào)用將產(chǎn)生相同的結(jié)果。

的輸出Html.Partial在變量中或從方法返回變量時(shí),不可能做這件事Html.RenderPartial..結(jié)果將寫(xiě)入Response執(zhí)行/評(píng)估期間的流。

這也適用于Html.ActionHtml.RenderAction.


查看完整回答
反對(duì) 回復(fù) 2019-06-20
?
慕田峪7331174

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超13個(gè)贊

將@Html.Partial看作復(fù)制到父頁(yè)面中的HTML代碼??梢詫Html.RenderPartial看作是合并到父頁(yè)面中的.ascx用戶(hù)控件。.ascx用戶(hù)控件的開(kāi)銷(xiāo)要大得多。

@html.Partial‘返回與父字符串內(nèi)聯(lián)構(gòu)造的html編碼字符串。它訪問(wèn)父母的模型。

@Html.RenderPartial‘返回等效的.ascx用戶(hù)控件。它自己獲取頁(yè)面的ViewDataDictionary副本,而對(duì)RenderPartial視圖數(shù)據(jù)所做的更改不會(huì)影響父視圖數(shù)據(jù)。

利用反射,我們發(fā)現(xiàn):

public static MvcHtmlString Partial(this HtmlHelper htmlHelper, string partialViewName, object model, ViewDataDictionary viewData){
    MvcHtmlString mvcHtmlString;
    using (StringWriter stringWriter = new StringWriter(CultureInfo.CurrentCulture))
    {
        htmlHelper.RenderPartialInternal(partialViewName, viewData, model, stringWriter, ViewEngines.Engines);
        mvcHtmlString = MvcHtmlString.Create(stringWriter.ToString());
    }
    return mvcHtmlString;}public static void RenderPartial(this HtmlHelper htmlHelper, string partialViewName){
    htmlHelper.RenderPartialInternal(partialViewName, htmlHelper.ViewData, null, htmlHelper.ViewContext.Writer, ViewEngines.Engines);}


查看完整回答
反對(duì) 回復(fù) 2019-06-20
?
慕無(wú)忌1623718

TA貢獻(xiàn)1744條經(jīng)驗(yàn) 獲得超4個(gè)贊

以下是我的發(fā)現(xiàn):

使用RenderAction如果您沒(méi)有要發(fā)送到視圖的模型,并且需要返回大量的html,則不需要將其存儲(chǔ)在變量中。

使用行動(dòng)當(dāng)您沒(méi)有要發(fā)送到視圖的模型,并且需要將需要存儲(chǔ)在變量中的少量文本帶回時(shí)。

使用倫德帕蒂當(dāng)您有一個(gè)模型要發(fā)送到視圖時(shí),將會(huì)有很多不需要存儲(chǔ)在變量中的html。

使用部分當(dāng)您有一個(gè)模型要發(fā)送到視圖時(shí),需要將少量文本存儲(chǔ)在變量中。

RenderAction倫德帕蒂更快。


查看完整回答
反對(duì) 回復(fù) 2019-06-20
  • 3 回答
  • 0 關(guān)注
  • 565 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)