本文整理汇总了C#中System.Web.UI.WebControls.LinkButton.ApplyStyle方法的典型用法代码示例。如果您正苦于以下问题:C# LinkButton.ApplyStyle方法的具体用法?C# LinkButton.ApplyStyle怎么用?C# LinkButton.ApplyStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.LinkButton
的用法示例。
在下文中一共展示了LinkButton.ApplyStyle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InstantiateIn
public void InstantiateIn (Control container)
{
Table table = new Table ();
table.ControlStyle.Width = Unit.Percentage (100);
table.ControlStyle.Height = Unit.Percentage (100);
// Row #0
table.Controls.Add (
CreateRow (new LiteralControl (_cPassword.SuccessTitleText), _cPassword.TitleTextStyle, HorizontalAlign.Center));
// Row #1
table.Controls.Add (
CreateRow (new LiteralControl (_cPassword.SuccessText), _cPassword.SuccessTextStyle, HorizontalAlign.Center));
// Row #3
WebControl ContinueButton = null;
switch (_cPassword.ChangePasswordButtonType) {
case ButtonType.Button:
ContinueButton = new Button ();
break;
case ButtonType.Image:
ContinueButton = new ImageButton ();
break;
case ButtonType.Link:
ContinueButton = new LinkButton ();
break;
}
ContinueButton.ID = "ContinueButton";
ContinueButton.ApplyStyle (_cPassword.ContinueButtonStyle);
((IButtonControl) ContinueButton).CommandName = ChangePassword.ContinueButtonCommandName;
((IButtonControl) ContinueButton).Text = _cPassword.ContinueButtonText;
((IButtonControl) ContinueButton).CausesValidation = false;
table.Controls.Add (
CreateRow (ContinueButton, null, HorizontalAlign.Right));
container.Controls.Add (table);
}
示例2: CreateChildControls
protected override void CreateChildControls()
{
LinkButton lnkPrevMon = new LinkButton();
lnkPrevMon.ID = "lnkPrevMon";
lnkPrevMon.Text = this.PrevMonthText;
lnkPrevMon.Click += new EventHandler(this.lnkPrevMon_OnClick);
this._lnkPrevMon = lnkPrevMon;
LinkButton lnkNextMon = new LinkButton();
lnkNextMon.ID = "lnkNextMon";
lnkNextMon.Text = this.NextMonthText;
lnkNextMon.Click += new EventHandler(this.lnkNextMon_OnClick);
this._lnkNextMon = lnkNextMon;
Style hdrTextStyle = new System.Web.UI.WebControls.Style();
hdrTextStyle.MergeWith(this._dayHdrStyle);
hdrTextStyle.BorderStyle = BorderStyle.None;
LinkButton lnkHdrSun = new LinkButton();
lnkHdrSun.ID = "lnkHdrSun";
lnkHdrSun.Text = this.GetDayName(DayOfWeek.Sunday);
lnkHdrSun.ApplyStyle(hdrTextStyle);
lnkHdrSun.CommandName = "ShowDay";
lnkHdrSun.CommandArgument = DayOfWeek.Sunday.ToString();
lnkHdrSun.Command += new CommandEventHandler(this.lnkHdr_OnCommand);
this._lnkHdrSun = lnkHdrSun;
LinkButton lnkHdrMon = new LinkButton();
lnkHdrMon.ID = "lnkHdrMon";
lnkHdrMon.Text = this.GetDayName(DayOfWeek.Monday);
lnkHdrMon.ApplyStyle(hdrTextStyle);
lnkHdrMon.CommandName = "ShowDay";
lnkHdrMon.CommandArgument = DayOfWeek.Monday.ToString();
lnkHdrMon.Command += new CommandEventHandler(this.lnkHdr_OnCommand);
this._lnkHdrMon = lnkHdrMon;
LinkButton lnkHdrTue = new LinkButton();
lnkHdrTue.ID = "lnkHdrTue";
lnkHdrTue.Text = this.GetDayName(DayOfWeek.Tuesday);
lnkHdrTue.ApplyStyle(hdrTextStyle);
lnkHdrTue.CommandName = "ShowDay";
lnkHdrTue.CommandArgument = DayOfWeek.Tuesday.ToString();
lnkHdrTue.Command += new CommandEventHandler(this.lnkHdr_OnCommand);
this._lnkHdrTue = lnkHdrTue;
LinkButton lnkHdrWed = new LinkButton();
lnkHdrWed.ID = "lnkHdrWed";
lnkHdrWed.Text = this.GetDayName(DayOfWeek.Wednesday);
lnkHdrWed.ApplyStyle(hdrTextStyle);
lnkHdrWed.CommandName = "ShowDay";
lnkHdrWed.CommandArgument = DayOfWeek.Wednesday.ToString();
lnkHdrWed.Command += new CommandEventHandler(this.lnkHdr_OnCommand);
this._lnkHdrWed = lnkHdrWed;
LinkButton lnkHdrThu = new LinkButton();
lnkHdrThu.ID = "lnkHdrThu";
lnkHdrThu.Text = this.GetDayName(DayOfWeek.Thursday);
lnkHdrThu.ApplyStyle(hdrTextStyle);
lnkHdrThu.CommandName = "ShowDay";
lnkHdrThu.CommandArgument = DayOfWeek.Thursday.ToString();
lnkHdrThu.Command += new CommandEventHandler(this.lnkHdr_OnCommand);
this._lnkHdrThu = lnkHdrThu;
LinkButton lnkHdrFri = new LinkButton();
lnkHdrFri.ID = "lnkHdrFri";
lnkHdrFri.Text = this.GetDayName(DayOfWeek.Friday);
lnkHdrFri.ApplyStyle(hdrTextStyle);
lnkHdrFri.CommandName = "ShowDay";
lnkHdrFri.CommandArgument = DayOfWeek.Friday.ToString();
lnkHdrFri.Command += new CommandEventHandler(this.lnkHdr_OnCommand);
this._lnkHdrFri = lnkHdrFri;
LinkButton lnkHdrSat = new LinkButton();
lnkHdrSat.ID = "lnkHdrSat";
lnkHdrSat.Text = this.GetDayName(DayOfWeek.Saturday);
lnkHdrSat.ApplyStyle(hdrTextStyle);
lnkHdrSat.CommandName = "ShowDay";
lnkHdrSat.CommandArgument = DayOfWeek.Saturday.ToString();
lnkHdrSat.Command += new CommandEventHandler(this.lnkHdr_OnCommand);
this._lnkHdrSat = lnkHdrSat;
// Create all link buttons for the days we're going to display.
if (this._lnkDates != null)
this._lnkDates.Clear();
this._lnkDates = new Collections.WebControlCollection();
DateTime curWkStart = this.GetCalFirstDay();
while (curWkStart.Date < this.dtCurMon.AddMonths(1))
{
DateTime curDay = curWkStart;
for (int i = 0; i < 7; i++)
{
LinkButton lnkDate = new LinkButton();
lnkDate.ID = "lnkDate_" + curDay.ToString("yyyyMMdd");
lnkDate.Text = curDay.Day.ToString();
lnkDate.CssClass = "date";
lnkDate.CommandName = "ShowDay";
lnkDate.CommandArgument = curDay.ToString("yyyyMMdd");
lnkDate.Command += new CommandEventHandler(this.lnkDate_OnCommand);
lnkDate.ApplyStyle((curDay.Month == this.dtCurMon.Month) ? this._curMonDateStyle : this._othMonDateStyle);
this._lnkDates.Add(lnkDate, curDay.ToString("yyyMMdd"));
//.........这里部分代码省略.........
示例3: InstantiateIn
public void InstantiateIn (Control container)
{
Table table = new Table ();
table.CellPadding = 0;
bool twoCells = _owner.TextLayout == LoginTextLayout.TextOnLeft;
// row 0
table.Rows.Add (
TemplateUtils.CreateRow (new LiteralControl (_owner.QuestionTitleText), null, _owner.TitleTextStyle, null, twoCells));
// row 1
table.Rows.Add (
TemplateUtils.CreateRow (new LiteralControl (_owner.QuestionInstructionText), null, _owner.InstructionTextStyle, null, twoCells));
// row 2
Literal UserNameLiteral = new Literal ();
UserNameLiteral.ID = "UserName";
table.Rows.Add (
TemplateUtils.CreateRow (new LiteralControl (_owner.UserNameLabelText), UserNameLiteral, _owner.LabelStyle, _owner.LabelStyle, twoCells));
// row 3
Literal QuestionLiteral = new Literal ();
QuestionLiteral.ID = "Question";
table.Rows.Add (
TemplateUtils.CreateRow (new LiteralControl (_owner.QuestionLabelText), QuestionLiteral, _owner.LabelStyle, _owner.LabelStyle, twoCells));
// row 5
TextBox AnswerTextBox = new TextBox ();
AnswerTextBox.ID = "Answer";
AnswerTextBox.ApplyStyle (_owner.TextBoxStyle);
Label AnswerLabel = new Label ();
AnswerLabel.ID = "AnswerLabel";
AnswerLabel.AssociatedControlID = "Answer";
AnswerLabel.Text = _owner.AnswerLabelText;
AnswerLabel.ApplyStyle (_owner.LabelStyle);
RequiredFieldValidator AnswerRequired = new RequiredFieldValidator ();
AnswerRequired.ID = "AnswerRequired";
AnswerRequired.ControlToValidate = "Answer";
AnswerRequired.ErrorMessage = _owner.AnswerRequiredErrorMessage;
AnswerRequired.ToolTip = _owner.AnswerRequiredErrorMessage;
AnswerRequired.Text = "*";
AnswerRequired.ValidationGroup = _owner.ID;
AnswerRequired.ApplyStyle (_owner.ValidatorTextStyle);
if (twoCells) {
TableRow row = TemplateUtils.CreateRow (AnswerLabel, AnswerTextBox, null, null, twoCells);
row.Cells [1].Controls.Add (AnswerRequired);
table.Rows.Add (row);
}
else {
table.Rows.Add (TemplateUtils.CreateRow (AnswerLabel, null, null, null, twoCells));
TableRow row = TemplateUtils.CreateRow (AnswerTextBox, null, null, null, twoCells);
row.Cells [0].Controls.Add (AnswerRequired);
table.Rows.Add (row);
}
// row 6
Literal FailureText = new Literal ();
FailureText.ID = "FailureText";
if (_owner.FailureTextStyle.ForeColor.IsEmpty)
_owner.FailureTextStyle.ForeColor = System.Drawing.Color.Red;
table.Rows.Add (TemplateUtils.CreateRow (FailureText, null, _owner.FailureTextStyle, null, twoCells));
// row 7
WebControl SubmitButton = null;
switch (_owner.SubmitButtonType) {
case ButtonType.Button:
SubmitButton = new Button ();
break;
case ButtonType.Image:
SubmitButton = new ImageButton ();
break;
case ButtonType.Link:
SubmitButton = new LinkButton ();
break;
}
SubmitButton.ID = "SubmitButton";
SubmitButton.ApplyStyle (_owner.SubmitButtonStyle);
((IButtonControl) SubmitButton).CommandName = PasswordRecovery.SubmitButtonCommandName;
((IButtonControl) SubmitButton).Text = _owner.SubmitButtonText;
((IButtonControl) SubmitButton).ValidationGroup = _owner.ID;
TableRow buttonRow = TemplateUtils.CreateRow (SubmitButton, null, null, null, twoCells);
buttonRow.Cells [0].HorizontalAlign = HorizontalAlign.Right;
table.Rows.Add (buttonRow);
// row 8
table.Rows.Add (
TemplateUtils.CreateHelpRow (
_owner.HelpPageUrl, _owner.HelpPageText, _owner.HelpPageIconUrl, _owner.HyperLinkStyle, twoCells));
container.Controls.Add (table);
}
示例4: RenderEventRow
protected void RenderEventRow(HtmlTextWriter writer, DateTime rowStart)
{
DateTime rowEnd = rowStart.Date.AddDays(6);
writer.AddAttribute(HtmlTextWriterAttribute.Class, "events");
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
CalendarEvent[] events = this._provider.GetEvents(this.DisplayUserKey, rowStart.Date, rowEnd.Date);
if (events.Length == 0)
{
for (int i = 0; i < 7; i++)
this.RenderEmptyEvent(writer);
}
else
{
Style eventTextStyle = new Style();
eventTextStyle.MergeWith(this._eventStyle);
eventTextStyle.BorderStyle = BorderStyle.None;
List<CalendarEvent> unrenderedEvents = new List<CalendarEvent>(events);
DateTime curDay = rowStart;
while (unrenderedEvents.Count > 0)
{
// Doing the event this way, lets us put multiple events on the same
// row, so long as they don't "interfere" with each other.
CalendarEvent curEv = null;
if (curDay.Date == rowStart.Date)
// Make sure that we only allow events to occured before the
// "current" date if we're on the first cell in the row.
curEv = unrenderedEvents.Where(e => e.EventStartDate.Date <= curDay.Date).FirstOrDefault();
else
curEv = unrenderedEvents.Where(e => e.EventStartDate.Date == curDay.Date).FirstOrDefault();
while (curEv == null && curDay.Date <= rowEnd.Date)
{
this.RenderEmptyEvent(writer);
curDay = curDay.AddDays(1);
curEv = unrenderedEvents.Where(e => e.EventStartDate.Date == curDay.Date).FirstOrDefault();
}
if (curEv == null)
{
// If we still have no current event at this point, end this row,
// start a new one, and let the search start over.
curDay = rowStart;
writer.RenderEndTag(); // TR (event row)
writer.AddAttribute(HtmlTextWriterAttribute.Class, "events");
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
}
else
{
// Now, we write the actual event.
int eventDays = curEv.EventEndDate.Date <= rowEnd.Date
? (int)System.Math.Ceiling(curEv.EventEndDate.Subtract(curDay).TotalDays)
: (int)System.Math.Ceiling(rowEnd.Subtract(curDay).TotalDays) + 1;
if (eventDays > 1)
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, eventDays.ToString());
if (curEv.EventStartDate < rowStart && curEv.EventEndDate > rowEnd)
writer.AddAttribute(HtmlTextWriterAttribute.Class, "evMid");
else if (curEv.EventStartDate < rowStart)
writer.AddAttribute(HtmlTextWriterAttribute.Class, "evEnd");
else if (curEv.EventEndDate > rowEnd)
writer.AddAttribute(HtmlTextWriterAttribute.Class, "evStart");
else
writer.AddAttribute(HtmlTextWriterAttribute.Class, "evFull");
if (this.ControlStyle != null)
{
System.Web.UI.WebControls.Style tdStyle = new Style();
tdStyle.BorderStyle = this.ControlStyle.BorderStyle;
tdStyle.BorderColor = this.ControlStyle.BorderColor;
tdStyle.BorderWidth = this.ControlStyle.BorderWidth;
tdStyle.ForeColor = this.ControlStyle.ForeColor;
tdStyle.BackColor = this.ControlStyle.BackColor;
tdStyle.AddAttributesToRender(writer);
}
writer.RenderBeginTag(HtmlTextWriterTag.Td);
//if (curEv.EventStartDate < rowStart && curEv.EventEndDate > rowEnd)
// writer.AddAttribute(HtmlTextWriterAttribute.Class, "evMid");
//else if (curEv.EventStartDate < rowStart)
// writer.AddAttribute(HtmlTextWriterAttribute.Class, "evEnd");
//else if (curEv.EventEndDate > rowEnd)
// writer.AddAttribute(HtmlTextWriterAttribute.Class, "evStart");
//else
// writer.AddAttribute(HtmlTextWriterAttribute.Class, "evFull");
this._eventStyle.AddAttributesToRender(writer);
writer.RenderBeginTag(HtmlTextWriterTag.Div);
LinkButton lnkEvent = new LinkButton();
lnkEvent.ID = "lnkEvent_" + curEv.ProviderEventKey + "_" + curDay.ToString("yyyyMMdd");
lnkEvent.Text = (curEv.EventStartDate.Date == curDay.Date)
? string.Format("{0} {1}", curEv.EventStartDate.ToString(System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortTimePattern), curEv.Subject)
: string.Format("<< {0}", curEv.Subject);
lnkEvent.ApplyStyle(eventTextStyle);
lnkEvent.CommandName = "ShowEvent";
lnkEvent.CommandArgument = curEv.ProviderEventKey.ToString();
lnkEvent.Command += new CommandEventHandler(this.lnkEvent_Command);
this.Controls.Add(lnkEvent);
lnkEvent.RenderControl(writer);
//.........这里部分代码省略.........