string result = string.Empty;
string strPost = "qf=xml&xml=" + HttpUtility.UrlEncode(xml);
StreamWriter myWriter = null;
HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(RequestUrl);
objRequest.Method = "POST";
objRequest.ContentLength = strPost.Length;
objRequest.ContentType = "application/x-www-form-urlencoded";
objRequest.KeepAlive = false;
try
{
myWriter = new StreamWriter(objRequest.GetRequestStream());
myWriter.Write(strPost);
}
catch (Exception ex)
{
litResult.Text = ex.Message;
}
finally
{
myWriter.Close();
}
HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
The trick to passing data from Javascript and Asp.Net is to use hidden inputs in the html. The hidden inputs should have the runat="server" attribute. For example: <input type="hidden" runat="server" id="hiddenfield" value="" /> Then in the Javascript, whatever value you are trying to pull from Asp.Net, set the hidden field using: document.getElementById("hiddenfield").value = "whatever value you want to set" And in the Asp.net form, you can just access the hiddenfield by using its id. string x = hiddenfield.value.text Thats all there is to it. You might need to check the syntax of it first as this is just all from my head.
Comments