Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 16th, 2008, 2:17 PM   #1
ivan
Professional Programmer
 
ivan's Avatar
 
Join Date: Sep 2005
Location: serbia & montenegro
Posts: 484
Rep Power: 4 ivan is on a distinguished road
c# and web forms

Hi,

I want to use web form in this page http://www.belestrane.nadlanu.com/site/ in my c# application. I need to somehow post the data from controls in the app and then output them on a listbox. I think i should use webservices but I am not sure.

Thank you
__________________
ivankorhner.co.sr
ivan is offline   Reply With Quote
Old Jul 16th, 2008, 8:51 PM   #2
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 763
Rep Power: 3 Jimbo is on a distinguished road
Re: c# and web forms

You mean you want to use that form in a C# client application? If so, you'll need to recreate the form in your app; there isn't a way to randomly include the webform data in your C# app. If you're trying to get it through a service, there needs to be a service there already; it will have a separate URL than the webpage.
__________________
<insert disclaimer here>
<insert shameless plug for Visual Studio here>
Jimbo is offline   Reply With Quote
Old Jul 18th, 2008, 4:09 AM   #3
ivan
Professional Programmer
 
ivan's Avatar
 
Join Date: Sep 2005
Location: serbia & montenegro
Posts: 484
Rep Power: 4 ivan is on a distinguished road
Re: c# and web forms

Quote:
Originally Posted by Jimbo View Post
You mean you want to use that form in a C# client application? If so, you'll need to recreate the form in your app; there isn't a way to randomly include the webform data in your C# app. If you're trying to get it through a service, there needs to be a service there already; it will have a separate URL than the webpage.
Hi,

Thanks for your answer. I am trying to get the data by a http POST method.
With some packet sniffing i have found out how to send the variables but seems like I am not getting a correct response. Here is some code:

WebRequest wReq = WebRequest.Create("http://www.telekom.yu/WhitePages/ResultPage.asp");
wReq.Method = "POST";
wReq.UseDefaultCredentials = true;

string postData = "Telefon=&Ulica=&MG=022&Ime=&Broj=&Mesto=&Prezime=KORHNER";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);

wReq.ContentType = "application/x-www-form-urlencoded";
wReq.ContentLength = byteArray.Length;

Stream dataStream = wReq.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();

WebResponse wRes = wReq.GetResponse();
this.Text = ((HttpWebResponse)wRes).StatusDescription.ToString();

dataStream = wRes.GetResponseStream();

StreamReader stReader = new StreamReader(dataStream);
txtOutput2.Text = stReader.ReadToEnd();

stReader.Close();
dataStream.Close();
wRes.Close();
__________________
ivankorhner.co.sr
ivan is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:25 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC