Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Guys,
I would like to develop an UI in asp.net using C# for below kind of sample XML file.

I know we can go for XSLT transformations, after googling, in xslt we can mention plain HTML UI control. What I need to asp.net server controls and need to handle its events in code behind page.

I also know, in WPF after reading XML and prepare a xaml and give xaml to a render control, which will take care of displaying to UI

But I’m looking in asp.net webForm pages

Could anyone suggest best approach to follow with some samples?

Sample XML file
XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Root>
<Users>
	<FirstName value="TestFirst" />
	<LastName value="TestLast"/>
</Users>
<Machine>
	<Name value="" host="" sycTime="1" maxCount="10"  />
	<url>http://255.255.255:8008</url>
</Machine>
<UISampleOne>
	<Checkboxes value="true" />
	<Columns>
		<column columntext="FirstName" width=""  datatype="string" isreadonly="true" />
		<column columntext=" LastName " width="" datatype="date" isreadonly="false" />      
		<column columntext="Date" width="" datatype="date" isreadonly="false" />
   	 </Columns >
	<Filter>
        <FilterType value="FirstName" label="string" />
        <FilterType value="LastName" label="string" />
    </Filter>
</UISampleOne>
<UISampleTwo>
	<SectionOne>
		<FName value="SectionFName" />
		<LName value="SectionLName"/>
	</SectionOne>
	<SectionTwo>
		<FName value="SectionFName" />
		<LName value="SectionLName"/>
	</SectionTwo>
</UISampleTwo>
<UISampleThree>
	<ListsOne>
     	<list list_name="ListName1" list_path="/ABC/Xyz">
        	<item item_text="ItemText" item_name="ItemName1"/>
			<item item_text="ItemText" item_name="ItemName1"/>
     	 </list>
		<list list_name="ListName2" list_path="/ABC2/Xyz2">
        	<item item_text="ItemText" item_name="ItemName1"/>
			<item item_text="ItemText" item_name="ItemName1"/>
     	</list>
   	 </ListsOne >
	<ListsTwo>
     	<list list_name="ListName1" list_path="/ABC/Xyz">
        	<item item_text="ItemText" item_name="ItemName1"/>
			<item item_text="ItemText" item_name="ItemName1"/>
     	</list>
		<list list_name="ListName2" list_path="/ABC2/Xyz2">
        	<item item_text="ItemText" item_name="ItemName1"/>
			<item item_text="ItemText" item_name="ItemName1"/>
     	</list>
   	 </ListsTwo>    
</UISampleThree>
</Root>


What I have tried:

I know we can go for XSLT transformations, after googling, in xslt we can mention plain HTML UI control. What I need to asp.net server controls and need to handle its events in code behind page.

I also know, in WPF after reading XML and prepare a xaml and give xaml to a render control, which will take care of displaying to UI

But I’m looking in asp.net webForm pages
Posted
Updated 29-Jul-16 5:04am
v2
Comments
F-ES Sitecore 29-Jul-16 4:14am    
You're just going to have to interpret the xml and dynamically create the controls yourself. If you google "asp.net form builder" you'll probably find similar code examples as these techniques are generally used to build custom forms for gathering data.
Madhu J N 29-Jul-16 6:01am    
Thanks for your comment. Could you please share some samples.
ZurdoDev 29-Jul-16 10:46am    
Wait? You want to build a web form with server side controls using an XML file? Is that correct?
Madhu J N 29-Jul-16 12:51pm    
Hi Ryan,
Yes would like to create a web form with server controls like texbox, combo box, list box, etc.. and also handle their events in code behind page.
Thanks,
Madhu

1 solution

Hi,i can advise that you loop through the XML file and get the nodes.For example,i have used the below code to read the XML nodes in my xml file which i am getting the values in each node and then assigning to a variable.


XmlDocument xmlDocument = new XmlDocument();
               xmlDocument.LoadXml(yourxmlfilestring);


               XmlNodeList machineNodeList= xmlDocument.GetElementsByTagName("Machine");

               foreach (XmlNode value in machineNodeList)
               {
                   //while doing the loop here,get the actual values by using value.InnerText  to get the actual value
               }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900