C# 的新手我正在一个名为“PageFlex”的程序的结构中工作,该程序的所有结构都放在下面的代码中。我在此处发布此内容的主要原因是确保我正确格式化了我的脚本。如果这看起来格式正确,请告诉我。还有像 jsfiddle.net 这样的网站可以用于 C# 吗?
<script language="C#" runat="server">
string GetUserID(Pageflex.Ur.Storefront.Data.StorefrontAPI isini)
{
return isini.GetValue("SystemProperty", "LoggedOnUserID", null);
}
int GetShoppingCartCount()
{
Pageflex.Ur.Storefront.Data.StorefrontAPI isini =
new Pageflex.Ur.Storefront.Data.StorefrontAPI();
string userID = GetUserID(isini);
string[] docsInCart = isini.GetListValue("UserListProperty", "DocumentsInShoppingCart", userID);
return (docsInCart != null) ? docsInCart.Length : 0;
}
int GetShoppingCartTotal()
{
Pageflex.Ur.Storefront.Data.StorefrontAPI isini =
new Pageflex.Ur.Storefront.Data.StorefrontAPI();
string userID = GetUserID(isini);
string[] docsTotalPrice = isini.GetListValue("DocumentProperty", "DocumentPrice", userID);
return (docsTotalPrice != null) ? docsTotalPrice.Length : 0;
}
void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
int documentPrice = GetShoppingCartTotal();
priceCart.Text = shoppingPrice.ToString();
int shoppingCount = GetShoppingCartCount();
numCart.Text = shoppingCount.ToString();
ItemOrItems.Text = (shoppingCount == 1) ? "item" : "items";
}
}
</script>