本文整理汇总了C#中Form.AddFields方法的典型用法代码示例。如果您正苦于以下问题:C# Form.AddFields方法的具体用法?C# Form.AddFields怎么用?C# Form.AddFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Form
的用法示例。
在下文中一共展示了Form.AddFields方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFormWithData
//.........这里部分代码省略.........
Prompt = "Select your gender:",
Required = true,
Orientation = Orientation.Vertical
};
gender.AddChoices("Male,Female", ",");
gender.AddDataValue("Gender", "Male", true);
var email = new TextBox
{
DisplayOrder = 25,
ResponseTitle = "Email Address",
Prompt = "Enter your email address:",
Required = true,
RegexMessage = "Must be a valid email address",
RegularExpression = @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"
};
email.AddDataValue("EmailAddress", "[email protected]", true);
var sports = new CheckBoxList
{
DisplayOrder = 40,
ResponseTitle = "Favorite Sports",
Prompt = "What are your favorite sports?",
Orientation = Orientation.Horizontal
};
sports.AddChoices("Baseball,Football,Soccer,Basketball,Tennis,Boxing,Golf", ",");
sports.AddDataValue("Favorite Sports", "Cricket", true);
var states = new Select
{
DisplayOrder = 50,
ResponseTitle = "Visited States",
MultipleSelection = true,
Size = 10,
Prompt = "What US states have you visited? (Use the ctrl key to select multiple states.)"
};
states.AddChoices("Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,Louisiana,Maine,Maryland,Massachusetts,Michigan,Minnesota,Mississippi,Missouri,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,North Carolina,North Dakota,Ohio,Oklahoma,Oregon,Pennsylvania,Rhode Island,South Carolina,South Dakota,Tennessee,Texas,Utah,Vermont,Virginia,Washington,West Virginia,Wisconsin,Wyoming", ",");
states.AddDataValue("Visited States", "New York", true);
var bio = new TextArea
{
DisplayOrder = 60,
ResponseTitle = "Bio",
Prompt = "Describe yourself:"
};
bio.InputHtmlAttributes.Add("cols", "40");
bio.InputHtmlAttributes.Add("rows", "6");
bio.AddDataValue("Bio", "I am a software engineer.", true);
var month = new Select
{
DisplayOrder = 70,
ResponseTitle = "Month Born",
Prompt = "What month were you born in?",
ShowEmptyOption = true,
EmptyOption = "- Select One - "
};
month.AddChoices("January,February,March,April,May,June,July,August,September,October,November,December", ",");
month.AddDataValue("Month Born", "May", true);
var agree = new CheckBox
{
DisplayOrder = 80,
ResponseTitle = "Agrees To Terms",
Prompt = "I agree to all of the terms in the EULA.",
Required = true,
RequiredMessage = "You must agree to the EULA!"
};
agree.AddDataValue("Agree To Terms", "Yes", true);
var eula = new Literal
{
DisplayOrder = 75,
Html = string.Format(@"<textarea readonly=""readonly"" rows=""8"" cols=""60"">{0}</textarea>", GetEULA())
};
var file = new FileUpload
{
Prompt = "Your photo",
InvalidExtensionError = "Image files only.",
ValidExtensions = ".jpg,.gif,.png",
DisplayOrder = 73,
};
file.Validated += new ValidatedEventHandler(file_Validated);
file.Posted += new FilePostedEventHandler(file_Posted);
var hidden = new Hidden
{
ResponseTitle = "A Hidden Field",
Value = "some value"
};
// create form and add fields to it
var form = new Form();
form.AddFields(description, name, gender, email, sports, states, bio, month, agree, eula, file, hidden);
return form;
}
示例2: GetForm
//.........这里部分代码省略.........
Required = true,
RequiredMessage = "Your full name is required"
};
var gender = new RadioList
{
DisplayOrder = 30,
ResponseTitle = "Gender",
Prompt = "Select your gender:",
Required = true,
Orientation = Orientation.Vertical
};
gender.AddChoices("Male,Female", ",");
var email = new TextBox
{
DisplayOrder = 25,
ResponseTitle = "Email Address",
Prompt = "Enter your email address:",
Required = true,
RegexMessage = "Must be a valid email address",
RegularExpression = @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"
};
var sports = new CheckBoxList
{
DisplayOrder = 40,
ResponseTitle = "Favorite Sports",
Prompt = "What are your favorite sports?",
Orientation = Orientation.Horizontal
};
sports.AddChoices("Baseball,Football,Soccer,Basketball,Tennis,Boxing,Golf", ",");
var states = new Select
{
DisplayOrder = 50,
ResponseTitle = "Visited States",
MultipleSelection = true,
Size = 10,
Prompt = "What US states have you visited? (Use the ctrl key to select multiple states.)"
};
states.AddChoices("Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,Louisiana,Maine,Maryland,Massachusetts,Michigan,Minnesota,Mississippi,Missouri,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,North Carolina,North Dakota,Ohio,Oklahoma,Oregon,Pennsylvania,Rhode Island,South Carolina,South Dakota,Tennessee,Texas,Utah,Vermont,Virginia,Washington,West Virginia,Wisconsin,Wyoming", ",");
var bio = new TextArea
{
DisplayOrder = 60,
ResponseTitle = "Bio",
Prompt = "Describe yourself:"
};
bio.InputHtmlAttributes.Add("cols", "40");
bio.InputHtmlAttributes.Add("rows", "6");
var month = new Select
{
DisplayOrder = 70,
ResponseTitle = "Month Born",
Prompt = "What month were you born in?",
ShowEmptyOption = true,
EmptyOption = "- Select One - "
};
month.AddChoices("January,February,March,April,May,June,July,August,September,October,November,December", ",");
var agree = new CheckBox
{
DisplayOrder = 80,
ResponseTitle = "Agrees To Terms",
Prompt = "I agree to all of the terms in the EULA.",
Required = true,
RequiredMessage = "You must agree to the EULA!"
};
var eula = new Literal
{
DisplayOrder = 75,
Html = string.Format(@"<textarea readonly=""readonly"" rows=""8"" cols=""60"">{0}</textarea>", GetEULA())
};
var file = new FileUpload
{
Prompt = "Your photo",
InvalidExtensionError = "Image files only.",
ValidExtensions = ".jpg,.gif,.png",
Required = true,
DisplayOrder = 73,
};
file.Validated += new ValidatedEventHandler(file_Validated);
file.Posted += new FilePostedEventHandler(file_Posted);
var hidden = new Hidden
{
ResponseTitle = "A Hidden Field",
Value = "some value"
};
// create form and add fields to it
var form = new Form();
form.AddFields(description, name, gender, email, sports, states, bio, month, agree, eula, file, hidden);
return form;
}