本文整理汇总了C#中Anchor.CreateHtml方法的典型用法代码示例。如果您正苦于以下问题:C# Anchor.CreateHtml方法的具体用法?C# Anchor.CreateHtml怎么用?C# Anchor.CreateHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Anchor
的用法示例。
在下文中一共展示了Anchor.CreateHtml方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildHtmlPagination
/// <summary>
/// builds pagination links and return them as html string
/// </summary>
/// <param name="pagesNumberMax"></param>
/// <param name="page"></param>
/// <param name="functionString"></param>
/// <returns></returns>
public static string BuildHtmlPagination(int pagesNumberMax, int page, string functionString)
{
Div div = new Div();
if (pagesNumberMax > 4)
{
Anchor anchor = new Anchor();
Anchor anchor2 = new Anchor();
Anchor anchor3 = new Anchor();
Anchor anchor4 = new Anchor();
//jesli to pierwsza strona
if (page == 1)
{
//pokaz 1 i 2, postaw '...' jako link do ostatniej strony
anchor.CssClass = "aktywnyPag";
page += 1;
anchor.Text = 1.ToString();
anchor2.Text = (page).ToString();
anchor3.Text = (page + 1).ToString();
anchor4.Text = "...";
}
//jesli aktywna strona większa od 1 oraz mniejsza od maxPageNumber - 1 to:
else if (page > 1 && page < pagesNumberMax - 1)
{
//'...' jako pierwsza strona '...' jako ostatnia strona, pokaz obecny page oraz page+1
anchor2.CssClass = "aktywnyPag";
anchor.Text = "...";
anchor2.Text = (page).ToString();
anchor3.Text = (page + 1).ToString();
anchor4.Text = "...";
}
//jeśli aktywna strona to pageMax lub pageMax-1 to:
else if (page == pagesNumberMax || page == (pagesNumberMax - 1))
{
//'...' jako pierwszy, (pagesNumberMax-1) oraz pagesNumberMax jako numery
if (page == pagesNumberMax) { anchor4.CssClass = "aktywnyPag"; page -= 2; } else { anchor3.CssClass = "aktywnyPag"; page -= 1; }
anchor.Text = "...";
anchor2.Text = (page).ToString();
anchor3.Text = (page + 1).ToString();
anchor4.Text = pagesNumberMax.ToString();
}
anchor.ID = "link" + (1);
anchor2.ID = "link" + (page);
anchor3.ID = "link" + (page + 1);
anchor4.ID = "link" + (pagesNumberMax);
anchor.FunctionOnClick = functionString.Replace("this", "1");
anchor.FunctionOnClick = 1.ToString();
anchor2.FunctionOnClick = functionString.Replace("this", page.ToString());
anchor3.FunctionOnClick = functionString.Replace("this", page.ToString() + 1);
anchor4.FunctionOnClick = functionString.Replace("this", pagesNumberMax.ToString());
div.AddControll(anchor.CreateHtml());
div.AddControll(anchor2.CreateHtml());
div.AddControll(anchor3.CreateHtml());
div.AddControll(anchor4.CreateHtml());
}
else
{
for (int ii = 0; ii < pagesNumberMax; ii++)
{
Anchor anchor = new Anchor();
// anchor.PostBackUrl = "Odwiedzili.aspx?odwiedzili="+(ii+1);
anchor.Text = (ii + 1).ToString();
anchor.ID = "link" + (ii + 1);
anchor.FunctionOnClick += functionString.Replace("this", (ii + 1).ToString());
if ((ii + 1) == page)
anchor.CssClass = "aktywnyPag";
div.AddControll(anchor.CreateHtml());
}
}
return div.CreateDivHtml();
}