function
GetContents
(
BookID
)
{
$.
ajax(
{
type:
"POST",
url:
"tabletbook.aspx/GetContentsMenu",
data:
'{"BookID": "' +
BookID +
'"}',
contentType:
"application/json; charset=utf-8",
dataType:
"json",
success:
function (
msg)
{
ContentMenu =
msg.
d;
}
});
}
C#
- [WebMethod(true)]
- public static string GetContentsMenu(int BookID)
- {
- var BDC = new BookDC();
- var fb = BDC.GetBook(BookID);
- var sb = new StringBuilder();
- List<spGetChaptersResult> chaps = BDC.DataContext.spGetChapters(BookID).ToList();
- List<string> ChapsString = new List<string>();
- foreach (spGetChaptersResult chptr in chaps)
- {
- ChapsString.Add(chptr.PageNumber.ToString() + " " + " " + chptr.ChapterTitle);
-
- }
- string[] SortedChapterPages = ChapsString.ToArray();
- Array.Sort(SortedChapterPages, new Common.NaturalComparer());
- sb.Append("<div class='tabs-right'>");
- foreach (string scp in SortedChapterPages)
- {
- string outp = scp.Replace("'", "");
- sb.AppendLine("<ul>");
- sb.AppendLine("<li>");
- sb.AppendLine("<a href='#' id='pgNum'>");
- sb.AppendLine(" ");
- sb.AppendLine(outp);
- sb.AppendLine(" ");
- sb.AppendLine("</a>");
- sb.AppendLine("</li>");
- sb.AppendLine("</ul>");
- }
- sb.AppendLine("</div>");
- string cpret = sb.ToString();
- return cpret;
- }