0
請參閱附件截圖。我有一個複選框和一個按鈕,用於在ASP.Net頁面中回發帖子。我已經編寫了如下函數來確定在按鈕單擊事件中所有複選框已被選中:以下代碼是從ASP.Net調用的業務組件的一部分。請讓我知道如何將ActionArray返回到ASP.Net頁面中的調用functon。從ASP.Net遞歸函數返回Arraylist
public void checkBoxValidation(Control parent, string strKey)
{
XmlDocument getCyleXML = new XmlDocument();
string strChkID="", strActionXPath = "",strAction="";
ArrayList actionArray = new ArrayList();
// Loop through all the controls on the page
foreach (Control c in parent.Controls)
{
// Check and see if it's a checkbox.
if ((c.GetType() == typeof(CheckBox)))
{
// Since its a checkbox, see if this is checked.
if (((CheckBox)(c)).Checked == true)
{
// Find the ID of the checkbox
strChkID = ((CheckBox)(c)).ID.ToString();
getCyleXML = CycleXML(strKey);
strActionXPath = "/Actions/Action[checkbox='" + strChkID + "']/*[self::Name]";
strAction = getCyleXML.SelectSingleNode(strActionXPath).ToString();
actionArray.Add(strAction);
}
}
// Now we need to call itself (recursion) because all items (Panel, GroupBox, etc) is a container so we need to check
// all containers for any checkboxes.
if (c.HasControls())
{
checkBoxValidation(c, strKey);
}
}
}
在哪裏調用函數?你爲什麼不能返回列表?不要使用XmlDocument和ArrayList,而是使用XDocument和List。 –