本文整理汇总了C#中System.Web.UI.WebControls.Label类的典型用法代码示例。如果您正苦于以下问题:C# Label类的具体用法?C# Label怎么用?C# Label使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Label类属于System.Web.UI.WebControls命名空间,在下文中一共展示了Label类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\git\web-application-dev\online_album\App_Data\Database1.mdf;Integrated Security=True"); //创建连接对象
con.Open();
SqlCommand cmd = new SqlCommand("select * from [photo]", con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
Panel box = new Panel();
box.CssClass = "box";
Panel1.Controls.Add(box);
Image photo = new Image();
photo.CssClass = "photo";
photo.ImageUrl = "~/Images/" + dr["uid"].ToString() + "/" + dr["filename"].ToString(); ;
box.Controls.Add(photo);
box.Controls.Add(new Literal() { Text = "<br />" });
Label uid = new Label();
uid.Text = dr["uid"].ToString();
box.Controls.Add(uid);
box.Controls.Add(new Literal() { Text = "<br />" });
Label datetime = new Label();
datetime.Text = dr["datetime"].ToString();
box.Controls.Add(datetime);
}
}
示例2: GetAdministrationInterface
/// <summary>
/// Must create and return the control
/// that will show the administration interface
/// If none is available returns null
/// </summary>
public Control GetAdministrationInterface(Style controlStyle)
{
this._adminTable = new Table();
this._adminTable.ControlStyle.CopyFrom(controlStyle);
this._adminTable.Width = Unit.Percentage(100);
TableCell cell = new TableCell();
TableRow row = new TableRow();
cell.ColumnSpan = 2;
cell.Text = ResourceManager.GetString("NSurveySecurityAddinDescription", this.LanguageCode);
row.Cells.Add(cell);
this._adminTable.Rows.Add(row);
cell = new TableCell();
row = new TableRow();
CheckBox child = new CheckBox();
child.Checked = new Surveys().NSurveyAllowsMultipleSubmissions(this.SurveyId);
Label label = new Label();
label.ControlStyle.Font.Bold = true;
label.Text = ResourceManager.GetString("MultipleSubmissionsLabel", this.LanguageCode);
cell.Width = Unit.Percentage(50);
cell.Controls.Add(label);
row.Cells.Add(cell);
cell = new TableCell();
child.CheckedChanged += new EventHandler(this.OnCheckBoxChange);
child.AutoPostBack = true;
cell.Controls.Add(child);
Unit.Percentage(50);
row.Cells.Add(cell);
this._adminTable.Rows.Add(row);
return this._adminTable;
}
示例3: AgregarControles
protected void AgregarControles(Label nombreContr, CheckBox chB, TextBox tbox, HiddenField nuevoHidF, Label hrReg, Label observ)
{
try
{
PanelConVisita.Controls.Add(new LiteralControl("<tr>"));
PanelConVisita.Controls.Add(new LiteralControl("<td>"));
PanelConVisita.Controls.Add(nombreContr);
PanelConVisita.Controls.Add(new LiteralControl("</td><td>"));
PanelConVisita.Controls.Add(new LiteralControl(" "));
PanelConVisita.Controls.Add(new LiteralControl("</td><td>"));
if (hrReg == null)
{
PanelConVisita.Controls.Add(chB);
}
else
{
PanelConVisita.Controls.Add(hrReg);
}
PanelConVisita.Controls.Add(new LiteralControl("</td><td>"));
if (hrReg == null)
{
PanelConVisita.Controls.Add(tbox);
}
else
{
PanelConVisita.Controls.Add(observ);
}
PanelConVisita.Controls.Add(new LiteralControl("</td></tr>"));
}
catch (Exception ex)
{
return;
}
}
示例4: Flip
public static void Flip(Label lbl, ListControl lst, bool blnReadOnly)
{
lbl.Visible = blnReadOnly;
lst.Visible = !blnReadOnly;
if (blnReadOnly)
{
lbl.Text = "";
foreach (ListItem item in lst.Items)
{
if (item.Selected)
{
lbl.Text = lbl.Text + "<br>" + item.Text;
}
}
if (lbl.Text != "")
{
lbl.Text = lbl.Text.Remove(0, 4);
}
}
else
{
string str = lbl.Text.Replace("<br>", ",");
if (str != "")
{
foreach (string str2 in str.Split(new char[] { ',' }))
{
SelectedByText(lst, str2);
}
}
}
}
示例5: AddUpdatePanel
private void AddUpdatePanel(Panel p)
{
this.messageLabel = new Label();
this.updatePanel = new UpdatePanel();
this.updatePanel.ID = "ScrudUpdatePanel";
this.updatePanel.ChildrenAsTriggers = true;
this.updatePanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
this.updatePanel.ContentTemplateContainer.Controls.Add(this.topCommandPanel.GetCommandPanel("top"));
this.updatePanel.ContentTemplateContainer.Controls.Add(this.messageLabel);
this.updatePanel.ContentTemplateContainer.Controls.Add(this.gridPanel);
this.updatePanel.ContentTemplateContainer.Controls.Add(this.formPanel);
this.updatePanel.ContentTemplateContainer.Controls.Add(this.bottomCommandPanel.GetCommandPanel("bottom"));
//Bottom command panel.
this.userIdHidden = new HiddenField();
this.userIdHidden.ID = "UserIdHidden";
this.userIdHidden.Value = this.UserId.ToString(CultureInfo.InvariantCulture);
this.officeCodeHidden = new HiddenField();
this.officeCodeHidden.ID = "OfficeCodeHidden";
this.officeCodeHidden.Value = this.OfficeCode;
this.updatePanel.ContentTemplateContainer.Controls.Add(this.userIdHidden);
this.updatePanel.ContentTemplateContainer.Controls.Add(this.officeCodeHidden);
p.Controls.Add(this.updatePanel);
}
示例6: MultipleSelectControl
public MultipleSelectControl(MultipleSelect item, RepeatDirection direction)
{
this.item = item;
l = new Label();
l.Text = item.Title;
l.CssClass = "label";
l.AssociatedControlID = item.Name;
this.Controls.Add(l);
list = new CheckBoxList();
list.RepeatDirection = direction;
list.ID = item.Name;
list.CssClass = "alternatives";
list.DataSource = item.GetChildren();
list.DataTextField = "Title";
list.DataValueField = "ID";
list.DataBind();
this.Controls.Add(list);
if (item.Required)
{
cv = new CustomValidator { Display = ValidatorDisplay.Dynamic, Text = "*" };
cv.ErrorMessage = item.Title + " is required";
cv.ServerValidate += (s, a) => a.IsValid = !string.IsNullOrEmpty(AnswerText);
cv.ValidationGroup = "Form";
this.Controls.Add(cv);
}
}
示例7: showProjects
private void showProjects()
{
List<ProjectInfo> projects = ProjectInfo.getUserProjects(Membership.GetUser(false).UserName, activeProjectsOnly);
TableRow row = new TableRow();
Label cell = new Label();
cell.Text = "<div class = \"tblProjects\">";
int i = 0;
foreach (ProjectInfo info in projects)
{
if (i != 2)
{
cell.Text = "<img src=\"images\\tools_white.png\"/><a href =\"section.aspx?id=" + info.ProjectID + "\"><div class = projName>" + info.Name + "</div></a>"
+ "<div class = projDesc>" + info.Description + "</div>";
TableCell cell1 = new TableCell();
cell1.Text = cell.Text.ToString();
row.Cells.Add(cell1);
i++;
}
else
{
cell.Text = "<img src=\"images\\tools_white.png\"/><a href =\"section.aspx?id=" + info.ProjectID + "\"><div class = projName>" + info.Name + "</div></a>"
+ "<div class = projDesc>" + info.Description + "</div></tr><tr>";
TableCell cell1 = new TableCell();
cell1.Text = cell.Text.ToString();
row.Cells.Add(cell1);
i = 0;
}
}
tblProjects.Rows.Add(row);
cell.Text += "</div>";
}
示例8: Registration_Click
protected void Registration_Click(object sender, EventArgs e)
{
var firstName = new Label();
firstName.Text = "FirstName: " + this.firstName.Text + "<br/>";
this.MainForm.Controls.Add(firstName);
var lastName = new Label();
lastName.Text = "LastName: " + this.lastName.Text + "<br/>";
this.MainForm.Controls.Add(lastName);
var number = new Label();
number.Text = "Faculty Number: " + this.fNumber.Text + "<br/>";
this.MainForm.Controls.Add(number);
var university = new Label();
university.Text = "University: " + this.DropDownListUniversity.Text + "<br/>";
this.MainForm.Controls.Add(university);
var specialy = new Label();
specialy.Text = "Specialy: " + this.DropDownListSpecialy.Text + "<br/>";
this.MainForm.Controls.Add(specialy);
var courses = new Label();
var selectedItems = new List<string>();
foreach (var index in this.ListBoxCourses.GetSelectedIndices())
{
selectedItems.Add(this.ListBoxCourses.Items[index].Text);
}
courses.Text = "Courses: " + string.Join(", ", selectedItems) + "<br/>";
this.MainForm.Controls.Add(courses);
}
示例9: CreateChildControls
protected override void CreateChildControls()
{
lbl = new Label();
lbl.EnableViewState = false;
lbl.Text = UserGreeting;
this.Controls.Add(lbl);
}
示例10: View
/// <summary>
/// Initializes a new instance of the <see cref="View" /> class.
/// </summary>
protected View()
: base(HtmlTextWriterTag.Div)
{
Presenter = new Presenter(this);
_answerCountLabel = new Label()
{
Text = ResourceHelper.GetString("AnswerCountDropDownLabel")
};
_answerCountDropDown = new DropDownList()
{
AutoPostBack = true
};
QuestionComposerControl = new QuestionComposer()
{
QuestionLabelText = ResourceHelper.GetString("QuestionLabelText"),
AnswerLabelText = ResourceHelper.GetString("AnswerLabelText"),
FractionLabelText = ResourceHelper.GetString("FractionLabelText"),
ValidatorErrorMessage = ResourceHelper.GetString("FractionValidatorErrorMessage"),
IsVisibleLabelText = ResourceHelper.GetString("IsVisibleLabelText")
};
_generateXmlButton = new Button()
{
Text = ResourceHelper.GetString("GenerateXMLButtonText")
};
_generateXmlButton.Click += GenerateXmlButton_Click;
}
示例11: CreateChildControls
protected override void CreateChildControls()
{
Random random = new Random();
_firstInt = random.Next(0, 20);
_secondInt = random.Next(0, 20);
ResourceManager rm = new ResourceManager("SystemWebExtensionsAUT.LocalizingClientResourcesWalkthrough.VerificationResources", this.GetType().Assembly);
Controls.Clear();
_firstLabel = new Label();
_firstLabel.ID = "firstNumber";
_firstLabel.Text = _firstInt.ToString();
_secondLabel = new Label();
_secondLabel.ID = "secondNumber";
_secondLabel.Text = _secondInt.ToString();
_answer = new TextBox();
_answer.ID = "userAnswer";
_button = new Button();
_button.ID = "Button";
_button.Text = rm.GetString("Verify");
_button.OnClientClick = "return CheckAnswer();";
Controls.Add(_firstLabel);
Controls.Add(new LiteralControl(" + "));
Controls.Add(_secondLabel);
Controls.Add(new LiteralControl(" = "));
Controls.Add(_answer);
Controls.Add(_button);
}
示例12: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
var nearby = client.Nearby(client.ClientIdentifier, client.ClientSecret, new Decimal(41.58454600), new Decimal(-93.63416700));
if (!nearby.Any())
{
var l = new Label();
l.Text = "No spots found.";
this.nearbyHolder.Controls.Add(l);
}
else
{
foreach (NearbyResult spot in nearby)
{
var table = WebUIUtility.BuildFieldDescTable(
new Tuple<string, string>[] {
Tuple.Create("Id", spot.Id),
Tuple.Create("Name", spot.Name),
Tuple.Create("Latitude", spot.Latitude.ToString()),
Tuple.Create("Longitude", spot.Longitude.ToString()),
Tuple.Create("Address", spot.Address),
Tuple.Create("City", spot.City),
Tuple.Create("State", spot.State),
Tuple.Create("PostalCode", spot.PostalCode),
Tuple.Create("Group", string.Join(",", spot.Group)),
Tuple.Create("Image", spot.Image)
}
);
this.nearbyHolder.Controls.Add(table);
this.nearbyHolder.Controls.Add(WebUIUtility.HorizontalLine());
}
}
}
示例13: GetDesignTimeHtml
/// -----------------------------------------------------------------------------
/// <summary>
/// This class allows us to render the design time mode with custom HTML
/// </summary>
/// <remarks>
/// </remarks>
/// <history>
/// [Jon Henning] 9/20/2006 Commented
/// </history>
/// -----------------------------------------------------------------------------
public override string GetDesignTimeHtml()
{
string strText;
DNNToolBar objToolbar = (DNNToolBar)base.Component;
StringWriter sw = new StringWriter();
HtmlTextWriter tw = new HtmlTextWriter(sw);
Label objLabel;
Label objPanelTB;
objPanelTB = new Label();
//objPanelTB.Text = "[" & objToolbar.Target & " toolbar]"
if (!String.IsNullOrEmpty(objToolbar.CssClass)) objPanelTB.CssClass = objToolbar.CssClass;
foreach (DNNToolBarButton objBtn in objToolbar.Buttons) {
objLabel = new Label();
if (!String.IsNullOrEmpty(objBtn.CssClass)) objLabel.CssClass = objBtn.CssClass;
if (!String.IsNullOrEmpty(objBtn.Text)) objLabel.Text = objBtn.Text;
objPanelTB.Controls.Add(objLabel);
}
objPanelTB.Style.Add("position", "");
objPanelTB.Style.Add("top", "0px");
objPanelTB.Style.Add("left", "0px");
objPanelTB.RenderControl(tw);
return sw.ToString();
return strText;
}
示例14: CreateChildControls
//Override the Create Child Controls event
protected override void CreateChildControls()
{
base.CreateChildControls();
//label for radio button list
lblTFQuestion = new Label();
lblTFQuestion.ID = "lblTFQuestion";
lblTFQuestion.AssociatedControlID = "uxTFQuestion";
lblTFQuestion.Text = QuestionText;
//create radio button list
uxTFQuestion = new RadioButtonList();
uxTFQuestion.ID = "uxTFQuestion";
//create validation for radio button list
reqTFQuestion = new RequiredFieldValidator();
reqTFQuestion.ID = "reqTFQuestion";
reqTFQuestion.Display = ValidatorDisplay.Dynamic;
reqTFQuestion.Text = "*";
reqTFQuestion.ControlToValidate = "uxTFQuestion";
reqTFQuestion.ErrorMessage = "No radio selection";
//create and add list items true and false
ListItem listTrue = new ListItem("true", "true");
ListItem listFalse = new ListItem("False", "False");
uxTFQuestion.Items.Add(listTrue);
uxTFQuestion.Items.Add(listFalse);
//add label, radio button list and validator to controls
Controls.Add(lblTFQuestion);
Controls.Add(uxTFQuestion);
Controls.Add(reqTFQuestion);
}
示例15: DataEditorControls
public override Control DataEditorControls(XmlNode xml, Dictionary<string, object> properties)
{
//properties should be multiType properties ie. Name, Description, Mandatory, Validation
Panel pnlDataEditor = new Panel();
Label lblDataEditor = new Label() { Text = properties["Name"].ToString() };
Literal litDescription = new Literal() { Text = properties["Description"].ToString() };
dtpDataEditor = new umbraco.uicontrols.DatePicker.DateTimePicker();
if (properties.ContainsKey("ShowTime"))
{
boolShowTime = bool.Parse(properties["ShowTime"].ToString());
dtpDataEditor.ShowTime = boolShowTime;
}
if (xml != null)
{
//Anything special about the xml? no - just do innertext
dtpDataEditor.DateTime = Convert.ToDateTime(xml.InnerText);
}
pnlDataEditor.Controls.Add(lblDataEditor);
pnlDataEditor.Controls.Add(litDescription);
pnlDataEditor.Controls.Add(dtpDataEditor);
if (xml != null)
{
//Anything special about the xml? no - just do innertext
dtpDataEditor.DateTime = Convert.ToDateTime(xml.InnerText);
}
return pnlDataEditor;
}
开发者ID:benaghaeipour,项目名称:4Ben.DataTypes.MultiType.PropertyTypes,代码行数:34,代码来源:MultiType_DateTimePicker.cs