I have an aspx app which needs to post data to a form and read the response.
-
Hi, I have an aspx app which needs to post data to a form and read the response. i try to use "webClient" and "HttpWebRequest" classes, but can not get response ? can you help me and get a refrence? please:((
function xmlhttpPost(strURL) { var xmlHttpReq = false; var self = this; // Mozilla/Safari if (window.XMLHttpRequest) { self.xmlHttpReq = new XMLHttpRequest(); } // IE else if (window.ActiveXObject) { self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } self.xmlHttpReq.open('POST', strURL, true); self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); self.xmlHttpReq.onreadystatechange = function() { if (self.xmlHttpReq.readyState == 4) { updatepage(self.xmlHttpReq.responseText); } } self.xmlHttpReq.send(getquerystring()); } function getquerystring() { var form = document.forms['f1']; var word = form.word.value; qstr = 'w=' + escape(word); // NOTE: no '?' before querystring return qstr; }
------------------------------------------------------ This is for posting....self.xmlHttpReq.send(getquerystring());
This is for getting the response....self.xmlHttpReq.responseText
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
-
function xmlhttpPost(strURL) { var xmlHttpReq = false; var self = this; // Mozilla/Safari if (window.XMLHttpRequest) { self.xmlHttpReq = new XMLHttpRequest(); } // IE else if (window.ActiveXObject) { self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } self.xmlHttpReq.open('POST', strURL, true); self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); self.xmlHttpReq.onreadystatechange = function() { if (self.xmlHttpReq.readyState == 4) { updatepage(self.xmlHttpReq.responseText); } } self.xmlHttpReq.send(getquerystring()); } function getquerystring() { var form = document.forms['f1']; var word = form.word.value; qstr = 'w=' + escape(word); // NOTE: no '?' before querystring return qstr; }
------------------------------------------------------ This is for posting....self.xmlHttpReq.send(getquerystring());
This is for getting the response....self.xmlHttpReq.responseText
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
-
Hi, I have an aspx app which needs to post data to a form and read the response. i try to use "webClient" and "HttpWebRequest" classes, but can not get response ? can you help me and get a refrence? please:((
you want to post data from an ASP.NET application to a form in another ASP.NET application ? Anyways to post data from a web form to another you can Add PostBackUrl="<YOUR_FORM_Path>" property to the submit button or use Server.Transfer and set the preserveForm parameter to True (for example Server.Transfer("<YOUR_FORM_Path>", True) ) Now to read post data you can use Request.Forms("") to access value for a specific control Hope this helps.
-
hi : Michael Sync tank you .:rose: your answer is with javaScript. can you get me an example with C# or VB.NET ?
Have you read Bassam Saoud's post?? maybe.. this is what you want..
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
-
Hi, I have an aspx app which needs to post data to a form and read the response. i try to use "webClient" and "HttpWebRequest" classes, but can not get response ? can you help me and get a refrence? please:((
-
you want to post data from an ASP.NET application to a form in another ASP.NET application ? Anyways to post data from a web form to another you can Add PostBackUrl="<YOUR_FORM_Path>" property to the submit button or use Server.Transfer and set the preserveForm parameter to True (for example Server.Transfer("<YOUR_FORM_Path>", True) ) Now to read post data you can use Request.Forms("") to access value for a specific control Hope this helps.
-
HttpWebRequest hReq = (HttpWebRequest)HttpWebRequest.Create(ReqUrl); HttpWebResponse hResp = (HttpWebResponse)hReq.GetResponse(); Stream str = hResp.GetResponseStream(); Can you be more specific about your problem??????