vicky said:
hello guys, there are some values in a asp.net page and i have to xml
encode them (convert them into some xml format ) and send them to some
other page(via querystring) and decode there to use those values. If
anybody can guide how to do it will be good.
If you need to pass values from one page to another via the query string,
then you don't need to xml encode them.
If you are using the query string then you can only pass string values from
one page to another, but that isn't normally a problem because its easy
enough to convert numeric values to and from a string. If however you need
to pass something more complex (i.e. an object) then you could serialise the
object and then pass it as a string, but if your objects are large then
passing them via the query string isn't optimum.
To build up your query string is quite straight forward. Lets say you have
two variables "A" and "B" then your query string would look something like:
example.com?A=1&B=2
so ? after the URL and & between subsequent variables.
At the other end you would get the value using (VB.Net - but the C# syntax
won't be too different):
int a = HttpContext.Current.Request.QueryString.Item("A")
int b = HttpContext.Current.Request.QueryString.Item("B")
When passing string values use HttpUtility.HtmlEncode to encode the string
(because spaces, ampersands and some other characters have special meanings)
and HttpUtility.HtmlDecode to decode the value at the destination page to
get back to the original string.
I hope that's sufficient to get you going.