当前位置: 首页>>代码示例>>C#>>正文


C# HtmlHelper.SerializedHidden方法代码示例

本文整理汇总了C#中System.Web.Mvc.HtmlHelper.SerializedHidden方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlHelper.SerializedHidden方法的具体用法?C# HtmlHelper.SerializedHidden怎么用?C# HtmlHelper.SerializedHidden使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Mvc.HtmlHelper的用法示例。


在下文中一共展示了HtmlHelper.SerializedHidden方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Serialized_Hidden_Returns_A_Hidden_Field_With_The_Entity_Serialized

        public void Serialized_Hidden_Returns_A_Hidden_Field_With_The_Entity_Serialized()
        {
            //Arrang
            Customer customer = new Customer();

            
            string serializedCustomer = new SelfTrackingEntityBase64Converter<Customer>().ToBase64(customer);
            
            ViewDataDictionary viewData = new ViewDataDictionary();
            
            SViewContext viewContext = new SViewContext();
            viewContext.ViewData = viewData;
            
            SIViewDataContainer viewDataContainer = new SIViewDataContainer();
            viewDataContainer.ViewDataGet = () => viewData;
            

            HtmlHelper<Customer> helper = new HtmlHelper<Customer>(viewContext, viewDataContainer);
            
            //Act
            MvcHtmlString result = helper.SerializedHidden(customer);
            
            //Assert
            //Parse the result (it creates XML-Compliant HTML)
            XElement element = XElement.Parse(result.ToHtmlString());

            //Ensure it's an input tag.
            Assert.AreEqual("input", element.Name.LocalName);

            //Ensure it's a hidden field.
            Assert.AreEqual("hidden",element.Attribute("type").Value);

            //Ensure it has the correct name
            Assert.AreEqual("CustomerSTE",element.Attribute("name").Value);

            //Ensure it has the correct id
            Assert.AreEqual("CustomerSTE",element.Attribute("id").Value);

            //Ensure the serialized customer is serialized correctly.
            Assert.AreEqual(serializedCustomer, element.Attribute("value").Value);
        }
开发者ID:ljvblfz,项目名称:MicrosoftNLayerApp,代码行数:41,代码来源:NLayerAppHtmlHelpersTests.cs

示例2: Serialized_Hidden_Returns_An_Empty_String_When_Entity_Is_Null

        public void Serialized_Hidden_Returns_An_Empty_String_When_Entity_Is_Null()
        {
            //Arrange
            ViewDataDictionary viewData = new ViewDataDictionary();

            
            SViewContext viewContext = new SViewContext();
            viewContext.ViewData = viewData;

            
            SIViewDataContainer viewDataContainer = new SIViewDataContainer();
            viewDataContainer.ViewDataGet = () => viewData;

            
            HtmlHelper<Customer> helper = new HtmlHelper<Customer>(viewContext, viewDataContainer);
            
            //Act
            MvcHtmlString result = helper.SerializedHidden(null);
            
            //Assert
            Assert.AreEqual(MvcHtmlString.Empty.ToHtmlString(), result.ToHtmlString());
        }
开发者ID:ljvblfz,项目名称:MicrosoftNLayerApp,代码行数:22,代码来源:NLayerAppHtmlHelpersTests.cs


注:本文中的System.Web.Mvc.HtmlHelper.SerializedHidden方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。