本文整理匯總了C#中Album.findById方法的典型用法代碼示例。如果您正苦於以下問題:C# Album.findById方法的具體用法?C# Album.findById怎麽用?C# Album.findById使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Album
的用法示例。
在下文中一共展示了Album.findById方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Page_Init
protected void Page_Init(object sender, EventArgs e)
{
// -- OUR CODE
// Cookie reading
DataTable cartTable = new DataTable();
cartTable.Columns.Add("Albums", typeof(string));
XmlDocument xmldoc2 = new XmlDocument();
foreach (string cookieName in Request.Cookies.AllKeys)
{
HttpCookie cookie = Request.Cookies[cookieName];
if (cookie.Name.Contains("cart_"))
{
int amount = int.Parse(cookie["amount"]);
Album album = new Album();
album = album.findById(int.Parse(cookie["id"]), Server);
DataRow dtrow = cartTable.NewRow();
dtrow["Albums"] = album.Artist + " - " + album.Title + " (" + amount + " x " + album.Price + " kr.)";
cartTable.Rows.Add(dtrow);
}
}
GridViewCart.DataSource = cartTable;
GridViewCart.DataBind();
// -- OUR CODE END
// The code below helps to protect against XSRF attacks
var requestCookie = Request.Cookies[AntiXsrfTokenKey];
Guid requestCookieGuidValue;
if (requestCookie != null && Guid.TryParse(requestCookie.Value, out requestCookieGuidValue))
{
// Use the Anti-XSRF token from the cookie
_antiXsrfTokenValue = requestCookie.Value;
Page.ViewStateUserKey = _antiXsrfTokenValue;
}
else
{
// Generate a new Anti-XSRF token and save to the cookie
_antiXsrfTokenValue = Guid.NewGuid().ToString("N");
Page.ViewStateUserKey = _antiXsrfTokenValue;
var responseCookie = new HttpCookie(AntiXsrfTokenKey)
{
HttpOnly = true,
Value = _antiXsrfTokenValue
};
if (FormsAuthentication.RequireSSL && Request.IsSecureConnection)
{
responseCookie.Secure = true;
}
Response.Cookies.Set(responseCookie);
}
Page.PreLoad += master_Page_PreLoad;
}