1
你好我想保存umbraco表格的值爲這個我已經使腳本文件,並在這個腳本文件我已經創建了函數來保存數據,並在同一腳本文件中調用此函數和這個腳本文件在宏中使用,我已經在我的頁面的模板中調用這個宏,但它不工作,這種方法是適當的,或者我不得不別的東西我的基本目標是保存數據庫中的數據,而不創建我的用戶控制通過腳本文件在umbraco中保存表格值
代碼
@functions
{
public void AddToCart()
{
string con = System.Configuration.ConfigurationManager.AppSettings["umbracoDbDSN"].ToString();
SqlConnection OnCon = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["umbracoDbDSN"].ToString());
ItemsDataContext db = new ItemsDataContext(con);
var request = HttpContext.Current.Request;
string itemcode= request.Form["ItemCode"].ToString();
string itemname = request.Form["ItemName"].ToString();
string itemcategory = Request.Form["ItemCategory"].ToString();
string userid = "Pallavi";
db.sp_AddItems(userid, itemcode, itemcategory, itemname, 0);
HttpContext.Current.Session["UserId"] = "Pallavi";
}
}
@if (!IsPost)
{
AddToCart();
}
,並呼籲該宏模板
<umbraco:Macro Alias="Uc_Cart" runat="server"></umbraco:Macro>
MakeNew方法中的最後一個參數是Document的parentID。它被保存爲這個父項的一個childItem。如果要將文檔保存在根目錄中,則在示例中使用-1作爲parentID – 2013-03-14 13:55:33
,通過使用hello User.GetUser(id)方法中的authorID獲取作者。如果您使用0,您將獲得Admin用戶,或者您可以使用任何其他現有用戶的ID。 – 2013-03-14 19:03:01
即時通訊沒有得到我的應用程序getuser方法和什麼概率發現是我的表單不張貼所以我能做什麼 – iProgrammer 2013-03-15 06:22:09