sending xml file to a remote server from automatically generated UI windows phone

helpmae

New Member
I am currently working on a project which automatically generates UI based on parsed xml data and sends back the user response as xml file to a remote server. I have 2 problems at the moment. One is getting the value of the textbox which are automatically generated and the second one is sending the xml file that i have generated even though the values that I retrieved from the automatically generated textbox are empty:Below is small part of the code that generates the UI but in which I am unable to get the texbox values: switch (questionItem.QType) { case "1": { recordAudio.IsEnabled = false; PivotItem[] pivotItemTQ = new PivotItem[gv.openTextTypeCount]; //Creat array of Elements based on the totol number of elements ListBox[] listBoxItemTQ = new ListBox[gv.openTextTypeCount]; // " StackPanel[] stackPanelItemTQ = new StackPanel[gv.openTextTypeCount]; // " TextBlock[] openTextQuestion = new TextBlock[gv.openTextTypeCount]; // " TextBox[] openTextAnswer = new TextBox[gv.openTextTypeCount];\[code\] openTextQuestion[openTQ] = new TextBlock(); //Instantiation of the textblock openTextAnswer[openTQ] = new TextBox(); // " stackPanelItemTQ[openTQ] = new StackPanel(); // " listBoxItemTQ[openTQ] = new ListBox(); // " pivotItemTQ[openTQ] = new PivotItem(); // " openTextQuestion[openTQ].Margin = new Thickness(10, 0, 0, 0); openTextQuestion[openTQ].FontSize = 24; openTextQuestion[openTQ].TextWrapping = TextWrapping.Wrap; openTextAnswer[openTQ].TextAlignment = TextAlignment.Left; openTextAnswer[openTQ].TextWrapping = TextWrapping.Wrap; openTextAnswer[openTQ].Width = 400; openTextAnswer[openTQ].AcceptsReturn = true; pivotItemTQ[openTQ].Header = (allQuestionCount + 1) + "/" + gv.totalNumberOfQuestions + " "; //Assign the header value to the pivot item openTextQuestion[openTQ].Text = questionItem.Qq_id + " " + questionItem.QItem; //Put question to control as a value to get displayed on the screen stackPanelItemTQ[openTQ].Children.Add(openTextQuestion[openTQ]); //add the question into the stackpanel created for open question types stackPanelItemTQ[openTQ].Children.Add(openTextAnswer[openTQ]); //add the answer control into the stackpanel created for open question types listBoxItemTQ[openTQ].Items.Add(stackPanelItemTQ[openTQ]); pivotItemTQ[openTQ].Content = listBoxItemTQ[openTQ]; cassqPivot.Items.Add(pivotItemTQ[openTQ]); this.answerList.Add(new Answers() //Add answer to the anwer list with the question id and type { answersOfQuestionItem = openTextAnswer[openTQ].Text, questionIdOfAnswer = questionItem.Qq_id, typeOfAnswer = questionItem.QType }); if (openTQ < openTextTypeCount) openTQ++; break; }\[/code\]Below is the code that generates the xml file n tries to send it to a remote server:public class Submit { public void buildXml(List answerList) { Globals gv = new Globals();
string xmlSend = "answerList.xml"; DateTime now = DateTime.Now; string stamp = now.ToString(); XmlWriterSettings settings = new XmlWriterSettings(); //settings.Indent = true;
using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream isoStorage = new IsolatedStorageFileStream(xmlSend, FileMode.OpenOrCreate, isoStore)) { using (XmlWriter writer = XmlWriter.Create(isoStorage, settings)) {\[code\] writer.WriteStartElement("surveyAnswer"); writer.WriteStartElement("timestamp"); writer.WriteAttributeString("stamp", stamp); writer.WriteEndElement(); writer.WriteStartElement("surveyId"); writer.WriteAttributeString("id", "238"); writer.WriteEndElement(); writer.WriteStartElement("userName"); writer.WriteAttributeString("name", "620"); writer.WriteEndElement(); foreach (var anwerItem in gv.answerList) { writer.WriteStartElement("item"); writer.WriteAttributeString("q_id", anwerItem.questionIdOfAnswer); writer.WriteAttributeString("type", anwerItem.typeOfAnswer); writer.WriteAttributeString("answer", anwerItem.answersOfQuestionItem); writer.WriteEndElement(); } writer.WriteFullEndElement(); writer.WriteEndDocument(); writer.Flush(); } } } string uri = "URI"; //Uri serviceUri = new Uri(uri); //HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceUri); //request.Method = "POST"; // Post method //request.ContentType = "text/xml charset=iso-8859-1"; // content type WebClient wc = new WebClient(); wc.Headers["Content-type"] = "text/xml"; wc.Encoding = Encoding.GetEncoding("ISO-8859-1"); string method = "POST"; try { using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication()) { IsolatedStorageFileStream isoFileStream = isoStore.OpenFile(xmlSend, FileMode.Open); using (StreamReader reader = new StreamReader(isoFileStream)) { //MessageBox.Show(reader.ReadToEnd()); wc.OpenWriteAsync(new Uri(uri, UriKind.Absolute), method, reader.ReadToEnd()); //wc.UploadStringAsync(new Uri(uri, UriKind.Absolute), method, reader.ReadToEnd()); } } } catch { } }\[/code\]Any help or suggestion is appreciated!
 
Back
Top