本文整理汇总了C#中System.Web.HttpParseException类的典型用法代码示例。如果您正苦于以下问题:C# HttpParseException类的具体用法?C# HttpParseException怎么用?C# HttpParseException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpParseException类属于System.Web命名空间,在下文中一共展示了HttpParseException类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetChildControlType
//引入命名空间
using System;
using System.Security.Permissions;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace Samples.AspNet.CS
{
// Define a child control for the custom HtmlSelect.
public class MyCustomOption
{
string _id;
string _value;
public string optionid
{
get
{ return _id; }
set
{ _id = value; }
}
public string value
{
get
{ return _value; }
set
{ _value = value; }
}
}
// Define a custom HtmlSelectBuilder.
public class MyHtmlSelectBuilderWithparseException : HtmlSelectBuilder
{
[AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
public override Type GetChildControlType(string tagName, IDictionary attribs)
{
// Distinguish between two possible types of child controls.
if (tagName.ToLower().EndsWith("mycustomoption"))
{
return typeof(MyCustomOption);
}
else
{
throw new HttpParseException("This custom HtmlSelect control" + "requires child elements of the form \"MyCustomOption\"");
}
}
}
[ControlBuilderAttribute(typeof(MyHtmlSelectBuilderWithparseException))]
public class CustomHtmlSelectWithHttpParseException : HtmlSelect
{
// Override the AddParsedSubObject method.
protected override void AddParsedSubObject(object obj)
{
string _outputtext;
if (obj is MyCustomOption)
{
_outputtext = "custom select option : " + ((MyCustomOption)obj).value;
ListItem li = new ListItem(_outputtext, ((MyCustomOption)obj).value);
base.Items.Add(li);
}
}
}
}