System.Web.WebPages.WebPageBase.DefineSection C# (CSharp) Method

DefineSection() public method

public DefineSection ( string name, SectionWriter action ) : void
name string
action SectionWriter
return void
        public void DefineSection(string name, SectionWriter action)
        {
            if (SectionWriters.ContainsKey(name))
            {
                throw new HttpException(String.Format(CultureInfo.InvariantCulture, WebPageResources.WebPage_SectionAleadyDefined, name));
            }
            SectionWriters[name] = action;
        }

Usage Example

Example #1
0
 private static void RenderSectionAsLayoutRegion(WebPageBase webPage, string partialViewHtml, string sectionName)
 {
     webPage.DefineSection(
         sectionName,
         () =>
         {
             Action<TextWriter> writerAction = tw => tw.Write(partialViewHtml);
             var result = new HelperResult(writerAction);
             webPage.Write(result);
         });
 }