Sorry for that... I explained but , i think i was not that much clear to you. Let me explain it in detail;
My application has an xml file, generated by some webservice. generated xml is below:
xml:
<CarrierEnrollmentForm>
<Coverage>
<RelationshipDaughter>false</RelationshipDaughter>
<RelationshipDependent>false</RelationshipDependent>
<RelationshipDomesticPartner>false</RelationshipDomesticPartner>
<RelationshipHusbant>false</RelationshipHusbant>
<RelationshipSelf>false</RelationshipSelf>
<RelationshipSon>false</RelationshipSon>
<RelationshipSpouse>false</RelationshipSpouse>
<RelationshipWife>false</RelationshipWife>
</Coverage>
</CarrierEnrollmentForm>
Below is my html dropdown combo mapped , that i placed in aspx file.
Code:
<select name="CEF_Coverage_Contingent_RelationshipDependent_ddl" id="CEF_Coverage_Contingent_RelationshipDependent_ddl">
<xsl:if test="/doc:CarrierEnrollmentForm/doc:Coverage/doc:Contingent/doc:RelationshipDependent = 'false'">
<option Value="Husband">Husband</option>
<option Value="Wife">Wife</option>
<option Value="Son">Son</option>
<option Value="Daughter">Daughter</option>
<option Value="Spouse">Spouse</option>
<option Value="Dependent">Dependent</option>
<option Value="Domestic">Domestic Partner</option>
</xsl:if>
</select>
I need to such a maping that If I select Son from UI then it will give me true or something so that i can set true to <RelationShipSon>true</RelationshipSon> in xml or i can determine that Son is selected. Similary if I select Spouse then it will yield the respective value of spouse and so on.
For example
For toggling Male and Female i have used:
Code:
<input type="radio" value="true" name="CEF_Employee_************_radiobutton" id="CEF_Employee_************_radiobutton" >
<xsl:choose>
<xsl:when test="/doc:CarrierEnrollmentForm/doc:Employee/doc:************='true'">
<xsl:attribute name="checked">1</xsl:attribute>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</input>
<label for="" class="fontnormal">Male</label>
<br></br>
<input type="radio" value="false" name="CEF_Employee_************_radiobutton" id="CEF_Employee_************_radiobutton">
<xsl:choose>
<xsl:when test="/doc:CarrierEnrollmentForm/doc:Employee/doc:************='false'">
<xsl:attribute name="checked">1</xsl:attribute>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</input>
<label for="" class="fontnormal">Female</label>
While parsing in CS i am using Request.Form[i] == true|false for getting radiobutton output.
CS Code
Code:
private void ParseHTMLControlValues()
{
XElement PrimaryXMLElement = XElement.Parse(_presenter.GetCarrierFormData(empID));
XNamespace xmlNameSpace = "http://schemas.datacontract.org/2004/07/BMES.WFC.DataContracts.CarrierFormData2";
for (int i = 0; i < Request.Form.Count; i++)
{
try
{
if (!Request.Form.Keys[i].StartsWith("CEF_")) continue;
string[] strArray = Request.Form.Keys[i].Replace("CEF_", "").Split('_');
XElement SecondaryXMLElement = PrimaryXMLElement;
foreach (string item in strArray)
{
//If the following conditions are true, remove the extra appended text from control name/id
//and then parse the form and set value to XML else let values remain as it is.
if ((item.ToLower().Trim() != "checkbox") &&
(item.ToLower().Trim() != "radiobutton") &&
(item.ToLower().Trim() != "ddl"))))
{
SecondaryXMLElement = SecondaryXMLElement.Element(xmlNameSpace + item);
}
}
//Query for checkbox control over entire form whose ID/Name ends with checkbox.
//Gets true/false from the form control state and sets true/false to the XML.
if ((Request.Form.Keys[i].ToLower()).EndsWith("checkbox"))
{
if (Request.Form[i].ToString().ToLower() == ",on")
{
SecondaryXMLElement.SetValue("true");
}
else
{
SecondaryXMLElement.SetValue("false");
}
}
//Query for radiobutton control over entire form whose ID/Name ends with radiobutton.
//Gets true/false from the form control state and sets true/false to the XML.
else if ((Request.Form.Keys[i].ToLower()).EndsWith("radiobutton"))
{
if (Request.Form[i].ToString() == "true")
{
SecondaryXMLElement.SetValue("true");
}
else
{
SecondaryXMLElement.SetValue("false");
}
}
/**********************************************************************
* BCBS Enrollment Form Special Handling Section *
**********************************************************************/
// For setting relationship of Primary Benificiary. Search for Coverage node under the XML then
// iterated that node for Primary benificiary/Relationship tag and if the tag matches with dropdown value,
//it sets the respective value in xml to true.
else if ((Page.Request.Form.Keys[i].ToLower()).EndsWith("bcbspbddl"))
{
XmlDocument xmldoc = new XmlDocument();
xmldoc.LoadXml(PrimaryXMLElement.ToString());
XmlNodeList xmlnode = xmldoc.GetElementsByTagName("Coverage");
//XmlElement root = xmldoc.DocumentElement;
for (int intCtr = 0; intCtr < xmlnode.Count; intCtr++)
{
XmlNodeList XChildNodes = xmlnode[intCtr].ChildNodes;
for (int ChildCtr = 0; ChildCtr < XChildNodes.Count; ChildCtr++)
{
if (XChildNodes[ChildCtr].Name.Contains("PrimaryBeneficiary"))
{
XmlNodeList SubChildNodes = XChildNodes[ChildCtr].ChildNodes;
for (int SubChildCtr = 0; SubChildCtr < SubChildNodes.Count; SubChildCtr++)
{
if (SubChildNodes[SubChildCtr].Name.Contains("Relationship"))
{
if (SubChildNodes[SubChildCtr].Name.Contains(Page.Request.Form[i].ToString()))
{
XmlNode innerSubChildNode = SubChildNodes[SubChildCtr];
innerSubChildNode.InnerXml = "true";
}
else
{
XmlNode innerSubChildNode = SubChildNodes[SubChildCtr];
innerSubChildNode.InnerXml = "false";
}
}
}
}
}
PrimaryXMLElement = XElement.Parse(xmldoc.InnerXml);
}
}
// For setting relationship of Contingent. Search for Coverage node under the XML then
// iterated that node for Relationship tag and if the tag matches with dropdown value,
//it sets the respective value in xml to true.
else if ((Page.Request.Form.Keys[i].ToLower()).EndsWith("bcbscddl"))
{
XmlDocument xmldoc = new XmlDocument();
xmldoc.LoadXml(PrimaryXMLElement.ToString());
XmlNodeList xmlnode = xmldoc.GetElementsByTagName("Coverage");
//XmlElement root = xmldoc.DocumentElement;
for (int intCtr = 0; intCtr < xmlnode.Count; intCtr++)
{
XmlNodeList XChildNodes = xmlnode[intCtr].ChildNodes;
for (int ChildCtr = 0; ChildCtr < XChildNodes.Count; ChildCtr++)
{
if (XChildNodes[ChildCtr].Name.Contains("Contingent"))
{
XmlNodeList SubChildNodes = XChildNodes[ChildCtr].ChildNodes;
for (int SubChildCtr = 0; SubChildCtr < SubChildNodes.Count; SubChildCtr++)
{
if (SubChildNodes[SubChildCtr].Name.Contains("Relationship"))
{
if (SubChildNodes[SubChildCtr].Name.Contains(Page.Request.Form[i].ToString()))
{
XmlNode innerSubChildNode = SubChildNodes[SubChildCtr];
innerSubChildNode.InnerXml = "true";
}
else
{
XmlNode innerSubChildNode = SubChildNodes[SubChildCtr];
innerSubChildNode.InnerXml = "false";
}
}
}
}
}
PrimaryXMLElement = XElement.Parse(xmldoc.InnerXml);
}
} else
{
string[] str = Request.Form[i].Split(',');
SecondaryXMLElement.SetValue(str[0]);
}
}
catch(Exception ex)
{
throw ex;
}
}
Session["updatedXML"] = null;
Session["updatedXML"] = PrimaryXMLElement.ToString();
//_presenter.SetCarrierFormData(PrimaryXMLElement.ToString(), empID);
Response.Redirect("CarrierForm.aspx?Carrier=" + Request.QueryString["Carrier"].ToString() + "&EmpID=" + empID + "&Mode=Disabled");
}