Click here to Skip to main content
15,885,952 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi ,

We are migrating the code from .net 2.0 to .net 4.0.During migration we are having a problem at Jquery,ajax and jason function.

In .net 2.0 the code was converting dataset to xml using below code
C#
stream = new MemoryStream();
               writer = new XmlTextWriter(stream, Encoding.Unicode);
               ds.WriteXml(writer);
               int count = (int)stream.Length;
               byte[] arr = new byte[count];
               stream.Seek(0, SeekOrigin.Begin);
               stream.Read(arr, 0, count);
               UnicodeEncoding utf = new UnicodeEncoding();
               return utf.GetString(arr).Trim();
           }

in jquery it is loading as xml.loadXMl(result).

When I try the same code in .net 4.0
Just adding .d to
VB
xml.loadXMl(result.d).

alerting the value it is coming as null.
When I hard code that xml xml.loadXMl(hardcoded xml )as it is working fin e.Where as when I print result.d it is coming fine but adding an extra character to xml.

Can any one help how to solve this?
Posted
Comments
Richard MacCutchan 5-Mar-13 6:06am    
You need to show the actual Javascript code where the problem occurs, also make sure that the XML data is correctly formed and accessible to the browser.
Prashant Bangaluru 5-Mar-13 7:01am    
I just found the error.When I am converting to XML it is adding a special character in front of XML .Hence the xml is not loading.But I dont know how to remove that..Can you help me now

Sorry, I don't event want to read your code. Any statements about jQuery working with any versions of .NET not just incorrect, they makes no sense at all and indicate your lack of understanding how Web works in principle.

This is because jQuery is a JavaScript library, and JavasScripts "knows" nothing about .NET, as well as any implementation detail of the server-side in general.

In turn, the source code you show (I still have to look at it) has nothing to do with jQuery. I see no evidence that something is not working. Any functionality can be screwed up if you don't understand the very basics.

What to do? Anyway, not to continue this project. First, try to learn how ASP.NET, HTTP, JavaScrip, jQuery work from first principles. Then come back to the project. Yes, I'm serious.

—SA
 
Share this answer
 
Comments
Prashant Bangaluru 5-Mar-13 1:50am    
I dont know JQuery that's why I am suspecting that it is problem with Jquery.Because when I loaded that xml with hardcoded value it is working but when I load the result.d nothing is showing..Its true I should learn the tech.
Sergey Alexandrovich Kryukov 5-Mar-13 2:21am    
Great idea. Learn it step by step and come back to the application.
Good luck,
—SA
Prashant Bangaluru 5-Mar-13 3:52am    
Thank You....
Hi ,I solved the above issue..It was because of the above code snippet when forming dataset to xml adding an special character.I rewritten the code without considering encoding.It worked fine.

C#
string result;
> using (StringWriter sw = new StringWriter()) {
> ds.WriteXml(sw);
> result = sw.ToString();
> }
 
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