本文整理汇总了C#中System.Web.UI.WebControls.LinkButton类的典型用法代码示例。如果您正苦于以下问题:C# LinkButton类的具体用法?C# LinkButton怎么用?C# LinkButton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LinkButton类属于System.Web.UI.WebControls命名空间,在下文中一共展示了LinkButton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindPager
public void BindPager()
{
panelPager.Controls.Clear();
var manager = new NotesManagerBusinessLogic();
var countOfNotes = manager.GetNotesCount();
var countOfPages = countOfNotes%10 == 0 ? countOfNotes/10 : countOfNotes/10 + 1;
if(countOfPages <= 1)
return;
for (var i = 1; i < countOfPages + 1; i++)
{
_linkButton = new LinkButton {ID = LinkId + i, Text = i.ToString()};
if (CurrentPage == i)
_linkButton.BackColor = Color.DarkGray;
PanelPager.Controls.Add(_linkButton);
var spacer = new Label { Text = " " };
PanelPager.Controls.Add(spacer);
}
}
示例2: Page_Init
protected void Page_Init(object sender, EventArgs e)
{
BlogCategoryDAL categoryDAL = new BlogCategoryDAL();
BlogEntryDAL entryDAL = new BlogEntryDAL();
//setup the accordion
this.Accordion.Panes.Clear();
foreach (BlogCategory category in categoryDAL.ReadBlogCategory(BlogTopic))
{
AjaxControlToolkit.AccordionPane pane = new AjaxControlToolkit.AccordionPane();
pane.ID = "pane" + category.Id;
LiteralControl header = new LiteralControl(string.Format("<div class = \"MenuHeader\"><b>{0}</b></div>", category.Category));
pane.HeaderContainer.Controls.Add(header);
pane.ContentContainer.Controls.Add(new LiteralControl("<ul style='margin-top:0; margin-bottom:0'>"));
foreach (BlogEntry entry in entryDAL.GetBlogEntries(category.Id))
{
LinkButton linkButton = new LinkButton();
linkButton.ID = "linkButton" + entry.Id;
linkButton.Text = entry.Subject;
linkButton.CommandArgument = entry.Id.ToString();
linkButton.Command += new CommandEventHandler(linkButton_Command);
linkButton.CausesValidation = false;
linkButton.CssClass = "MenuButton";
pane.ContentContainer.Controls.Add(new LiteralControl("<li>"));
pane.ContentContainer.Controls.Add(linkButton);
pane.ContentContainer.Controls.Add(new LiteralControl("</li>"));
}
pane.ContentContainer.Controls.Add(new LiteralControl("</ul>"));
this.Accordion.Panes.Add(pane);
}
}
示例3: InstantiateIn
public void InstantiateIn(Control objContainer)
{
LinkButton lnkbtn = new LinkButton();
lnkbtn.CommandName = strCommandName;
lnkbtn.DataBinding += new EventHandler(lnkbtn_DataBinding);
objContainer.Controls.Add(lnkbtn);
}
示例4: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
LinkButton child = new LinkButton();
child.Text = "All";
child.CssClass = "noUnderLine";
child.Font.Bold = true;
//child.Click += new EventHandler(this.btnAlpha_Click);
this.phdAlphaBar.Controls.Add(child);
char ch = 'A';
for (int i = 0; i < 26; i++)
{
Label label = new Label();
label.Text = " | ";
this.phdAlphaBar.Controls.Add(label);
LinkButton button2 = new LinkButton();
button2.Text = Convert.ToChar((int)(ch + i)).ToString();
button2.CssClass = "noUnderLine";
button2.Font.Bold = true;
//button2.Click += new EventHandler(this.btnAlpha_Click);
this.phdAlphaBar.Controls.Add(button2);
}
}
}
示例5: BuildStudentProspectTable
public static void BuildStudentProspectTable(Table table, string userId)
{
GroupService service = new GroupService();
DataTable dtProspects = service.GetProspectiveStudentsData(userId);
DataTable dtGroups = service.GetSupervisorOfData(userId);
for (int i = 0; i < dtProspects.Rows.Count; i++)
{
DropDownList ddlGroupList = new DropDownList();
ddlGroupList.DataSource = dtGroups;
ddlGroupList.DataTextField = "GroupName";
ddlGroupList.DataValueField = "GroupId";
ddlGroupList.DataBind();
ddlGroupList.Items.Insert(0, "Add a group");
string name = dtProspects.Rows[i].ItemArray[0].ToString();
string id = dtProspects.Rows[i].ItemArray[1].ToString();
LinkButton b = new LinkButton();
b.Text = name;
b.CommandArgument = id;
b.CommandName = name;
TableRow row = new TableRow();
TableCell cellProspects = new TableCell();
TableCell cellGroups = new TableCell();
cellProspects.Controls.Add(b);
cellGroups.Controls.Add(ddlGroupList);
row.Cells.Add(cellProspects);
row.Cells.Add(cellGroups);
table.Rows.Add(row);
}
}
示例6: OnBubbleEvent
/// <summary>
/// Captures a Delete command from a command button within the ListView. This code
/// assumes that each row contains a checkbox with an ID set to 'chkDelete'.
/// </summary>
/// <param name="source"></param>
/// <param name="e"></param>
/// <returns></returns>
protected override bool OnBubbleEvent(object source, EventArgs e)
{
if (e is CommandEventArgs)
{
switch (((CommandEventArgs) e).CommandName)
{
case "Delete":
bool result = false;
// loop through rows and delete item if checkbox is checked
foreach (ListViewDataItem listViewDataItem in Items)
{
CheckBox deleteCheckBox = listViewDataItem.FindControl("chkDelete") as CheckBox;
if (deleteCheckBox != null)
{
result = true;
if (deleteCheckBox.Checked)
DeleteItem(listViewDataItem.DisplayIndex);
}
}
if (result)
return true;
break;
case "Sort":
_sortButton = source as LinkButton;
break;
}
}
return base.OnBubbleEvent(source, e);
}
示例7: TodoGridView_RowDataBound
protected void TodoGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (IsPostBack)
{
if (e.Row.RowType == DataControlRowType.Header) //if header row has been clicked
{
LinkButton linkButton = new LinkButton();
for (int index = 0; index < TodoGridView.Columns.Count; index++)
{
if (TodoGridView.Columns[index].SortExpression == Session["SortColumn"].ToString())
{
if (Session["SortDirection"].ToString() == "ASC")
{
linkButton.Text = " <i class = 'fa fa-caret-up fa-lg'></i>";
}
else
{
linkButton.Text = " <i class = 'fa fa-caret-down fa-lg'></i>";
}
e.Row.Cells[index].Controls.Add(linkButton);
}
}
}
}
}
示例8: InitializeSkin
protected override void InitializeSkin(System.Web.UI.Control Skin)
{
repeater1 = (RepeaterPaged)Skin.FindControl("repeater1");
TextBox1 = (TextBox)Skin.FindControl("TextBox1");
LinkButton1 = (LinkButton)Skin.FindControl("LinkButton1");
LinkButton1.Click += new EventHandler(LinkButton1_Click);
DataBind();
if (blogContext.ID != -1)
{
if (BView_WeblogThemeCssFile.CheckExist(blogContext.ID))
{
if (!BWeblog_UserCss.CheckHasCssFile(blogContext.BlogUserId))
{
Weblog_UserCss WUC = new Weblog_UserCss();
WUC.UserCss_CssFileId = blogContext.ID;
WUC.UserCss_UserId = blogContext.BlogUserId;
WUC.UserCss_Used = true;
BWeblog_UserCss.Insert(WUC);
}
else//如果已经有了的话 更新
{
var temp= BWeblog_UserCss.GetByBlogUserId(blogContext.BlogUserId);
Weblog_UserCss WUC = new Weblog_UserCss();
WUC.UserCss_Id = temp.First().UserCss_Id;
WUC.UserCss_CssFileId = blogContext.ID;
WUC.UserCss_UserId = blogContext.BlogUserId;
WUC.UserCss_Used = true;
BWeblog_UserCss.Update(WUC);
}
Context.Response.Redirect("/" + blogContext.Owner.User_DomainName);
}
}
}
示例9: CreateChildControls
protected internal override void CreateChildControls()
{
this.Controls.Clear();
this._logInLinkButton = new LinkButton();
this._logInImageButton = new ImageButton();
this._logOutLinkButton = new LinkButton();
this._logOutImageButton = new ImageButton();
this._logInLinkButton.EnableViewState = false;
this._logInImageButton.EnableViewState = false;
this._logOutLinkButton.EnableViewState = false;
this._logOutImageButton.EnableViewState = false;
this._logInLinkButton.EnableTheming = false;
this._logInImageButton.EnableTheming = false;
this._logInLinkButton.CausesValidation = false;
this._logInImageButton.CausesValidation = false;
this._logOutLinkButton.EnableTheming = false;
this._logOutImageButton.EnableTheming = false;
this._logOutLinkButton.CausesValidation = false;
this._logOutImageButton.CausesValidation = false;
CommandEventHandler handler = new CommandEventHandler(this.LogoutClicked);
this._logOutLinkButton.Command += handler;
this._logOutImageButton.Command += handler;
handler = new CommandEventHandler(this.LoginClicked);
this._logInLinkButton.Command += handler;
this._logInImageButton.Command += handler;
this.Controls.Add(this._logOutLinkButton);
this.Controls.Add(this._logOutImageButton);
this.Controls.Add(this._logInLinkButton);
this.Controls.Add(this._logInImageButton);
}
示例10: CreateMainPaginatorControls
protected override Control[] CreateMainPaginatorControls(int fromPage, int toPage)
{
LinkButton[] linkArray = new LinkButton[toPage - fromPage];
for (int i = 0; i < linkArray.Length; i++)
{
linkArray[i] = new LinkButton();
linkArray[i].EnableViewState = false;
if (base.PageButtonTextFormat == null)
{
linkArray[i].Text = ((i + fromPage) + 1).ToString();
}
else
{
linkArray[i].Text = string.Format(base.PageButtonTextFormat, (i + fromPage) + 1);
}
linkArray[i].ID = (i + fromPage).ToString();
if ((i + fromPage) != base.PageIndex)
{
linkArray[i].Attributes.Add("onClick", string.Format("reloadRepeater({0});", i + fromPage));
}
else
{
linkArray[i].CssClass = "current";
}
}
return linkArray;
}
示例11: AttachChildControls
protected override void AttachChildControls()
{
this.favorites = (Common_Favorite_ProductList) this.FindControl("list_Common_Favorite_ProList");
this.btnSearch = ButtonManager.Create(this.FindControl("btnSearch"));
this.txtKeyWord = (TextBox) this.FindControl("txtKeyWord");
this.pager = (Pager) this.FindControl("pager");
this.btnDeleteSelect = (LinkButton) this.FindControl("btnDeleteSelect");
this.btnSearch.Click += new EventHandler(this.btnSearch_Click);
this.favorites.ItemCommand += new Common_Favorite_ProductList.CommandEventHandler(this.favorites_ItemCommand);
this.btnDeleteSelect.Click += new EventHandler(this.btnDeleteSelect_Click);
PageTitle.AddSiteNameTitle("商品收藏夹", HiContext.Current.Context);
if (!this.Page.IsPostBack)
{
if (!string.IsNullOrEmpty(this.Page.Request.QueryString["ProductId"]))
{
int result = 0;
int.TryParse(this.Page.Request.QueryString["ProductId"], out result);
if (!CommentsHelper.ExistsProduct(result) && !CommentsHelper.AddProductToFavorite(result))
{
this.ShowMessage("添加商品到收藏夹失败", false);
}
}
this.BindList();
}
}
示例12: OnLoad
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (Size != "16" & Size != "24" & Size != "32") Size = "32";
//NOTE: We need to recreate dynamically created controls on postback for them to pickup the event.
var enabledlanguages = LocaleController.Instance.GetLocales(PortalId);
Controls.Add(new LiteralControl("<ul class='editlanguage'>"));
foreach (var l in enabledlanguages)
{
Controls.Add(new LiteralControl("<li>"));
var cmd = new LinkButton();
cmd.Text = "<img src='" + StoreSettings.NBrightBuyPath() + "/Themes/config/img/flags/" + Size + "/" + l.Value.Code + ".png' alt='" + l.Value.EnglishName + "' />";
cmd.CommandArgument = l.Value.Code;
cmd.CommandName = "selectlang";
cmd.Command += (s, cmde) =>
{
var param = new string[2];
if (_entryid != "") param[0] = "eid=" + _entryid;
if (_ctrl != "") param[1] = "ctrl=" + _ctrl;
StoreSettings.Current.EditLanguage = cmde.CommandArgument.ToString();
Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
};
Controls.Add(cmd);
Controls.Add(new LiteralControl("</li>"));
}
Controls.Add(new LiteralControl("</ul>"));
}
示例13: DisplayButtonStatus
private void DisplayButtonStatus(Boolean isValidStatus, String invalidBallColor,
String validLinkText, String invalidLinkText,
Image linkImage, Label statusLabel = null,
LinkButton linkButton = null,
String onClientClickValidText = null, String onClientClickInvalidText = null)
{
if (isValidStatus)
{
linkImage.ImageUrl = "~/images/green-ball.gif";
if (linkButton != null)
{
linkButton.Text = validLinkText;
if (onClientClickValidText != null)
linkButton.OnClientClick = "return confirm('" + onClientClickValidText + "');";
}
if (statusLabel != null)
statusLabel.Text = validLinkText;
}
else
{
linkImage.ImageUrl = "~/images/" + invalidBallColor + "-ball.gif";
if (linkButton != null)
{
linkButton.Text = invalidLinkText;
if (onClientClickInvalidText != null)
linkButton.OnClientClick = "return confirm('" + onClientClickInvalidText + "');";
}
if (statusLabel != null)
statusLabel.Text = invalidLinkText;
}
}
示例14: IrGroupListRendering
private void IrGroupListRendering(JObject group)
{
var groupLink = new LinkButton();
var mainDiv = new HtmlGenericControl("div");
var name = new HtmlGenericControl("h5");
var description = new HtmlGenericControl("p");
groupLink.PostBackUrl = Request.Url.AbsolutePath;
groupLink.Attributes.Add("class", "irGroupLink list-item list-item-info");
groupLink.Attributes.Add("irGroupId", group["IrGroupId"].ToString());
mainDiv.Attributes.Add("id", "irGroupMainBlock");
mainDiv.Attributes.Add("class", ".form-inline");
name.Attributes.Add("id", "irGroupName");
name.Attributes.Add("class", "text-primary");
description.Attributes.Add("class", "irGroupDescription");
name.InnerText = group["Name"].ToString();
description.InnerText = group["Description"].ToString();
mainDiv.Controls.Add(name);
mainDiv.Controls.Add(description);
groupLink.Controls.Add(mainDiv);
LinkContainer.Controls.Add(groupLink);
}
示例15: CreateChildControls
protected override void CreateChildControls()
{
Label lbl = new Label();
lbl.ID = "lbl";
this.Controls.Add(lbl);
this.Controls.Add(new LiteralControl("<BR>"));
LinkButton btn = new LinkButton();
btn.ID = "btn";
btn.Text = "复合控件的事件测试";
this.Controls.Add(btn);
//给按钮添加内部事件
btn.Click += new EventHandler(btn_Click);
this.Controls.Add(new LiteralControl("<BR><a id=\"aa\" href=\"javascript:__doPostBack('EventTest1$btn','')\">aa</a>"));
this.Controls.Add(new LiteralControl("<BR><a id=\"a1\" href=\"javascript:__doPostBack('" + this.ClientID + "','1')\">[1]</a>"));
this.Controls.Add(new LiteralControl(" <a id=\"a2\" href=\"javascript:__doPostBack('" + this.ClientID + "','2')\">[2]</a>"));
this.Controls.Add(new LiteralControl(" <a id=\"a3\" href=\"javascript:__doPostBack('" + this.ClientID + "','3')\">[3]</a>"));
this.Controls.Add(new LiteralControl(" <a id=\"a4\" href=\"javascript:__doPostBack('" + this.ClientID + "','4')\">[4]</a>"));
}