我已經jQuery的使用AJAX/JSON抓住一個元素ID一個WebMethod可以使用,然後點擊:返回多個值jQuery中從
[System.Web.Services.WebMethod]
public static string EditPage(string nodeID)
{
DataTable dt = new DataTable();
using (SqlConnection con = new SqlConnection(Global.conString))
using (SqlCommand cmd = new SqlCommand("contentPageGetDetail", con))
{
cmd.Parameters.Add("@ID", SqlDbType.UniqueIdentifier).Value = Global.SafeSqlLiteral(nodeID, 1);
cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
da.Fill(dt);
}
}
if (dt.Count > 0)
{
string pageTitle = dt.Rows[0]["Title"].toString();
string contentID = dt.Rows[0]["ContentID"].toString();
return pageTitle, contentID, nodeID;
}
else
{
return "Failed";
}
}
當它的時間來恢復我想抓住所有的內容從返回存儲過程返回成功部分的jquery方法,並在文本字段中設置隱藏字段,下拉值和標題。
在jQuery中,我嘗試使用「pageTitle」,但它未定義。在顯示錶單之前,我需要做什麼來完成jQuery的工作以獲取返回的內容並填充Web窗體中的字段?
這是無效的語法。 – SLaks 2011-03-03 19:12:38
那是什麼呢? 'return pageTitle,contentID,nodeID;'? – hunter 2011-03-03 19:13:00
我需要返回的示例。我不知道返回多個字符串的正確方法。 – balexander 2011-03-03 19:13:52