2
這是一個普遍的問題,我沒有看到答案。我可以處理PostBack並進行不同的刷新嗎?
我可否告訴PostBack
與代碼刷新的區別以確保人們不會重複提交相同的商品?
應用程序是基於C#的ASP.NET。下面的代碼:
protected void SubmitListItem(object sender, EventArgs e)
{
if (Page.IsPostBack) //Fires on both submit and F5
{
SPUser user = web.CurrentUser;
string alias = user.Email.Substring(0, user.Email.IndexOf('@'));
if (ListChoice.SelectedItem.Text == "comment")
{
SPList TargetList = web.Lists.TryGetList("Offer Comments");
SPListItem item = TargetList.Items.Add();
item["Title"] = TitleBox.Text;
item["Body"] = BodyBox.Text;
item["OfferID"] = OfferID;
item["Alias"] = alias;
item.SystemUpdate();
TargetList.Update();
LoadOffers();
}
else
{
SPList TargetList = web.Lists.TryGetList("Offer Best Practices");
SPListItem item = TargetList.Items.Add();
item["Title"] = TitleBox.Text;
item["Body"] = BodyBox.Text;
item["OfferID"] = OfferID;
item.SystemUpdate();
TargetList.Update();
LoadOffers();
}
}
}
+1爲一個完美的單詞答案。 – jvenema 2011-12-13 18:05:58