G
Guest
Thanks in advance for any help offered.
I am trying to fill out a form on a web page and submit the form data to the
web server , all from within my vb program.
The html sorce ( reduced for this post is)
<FORM ACTION="a_valid_url.cfm" METHOD="POST">
<BR>
<P>Trend
<SELECT NAME="trend_id">
<OPTION VALUE="ALL;ALL">ALL
<OPTION VALUE="FIRST;abc">First
<OPTION VALUE="SECOND;abc">Second
</SELECT>
<P>
<TABLE WIDTH=400>
<TR ALIGN=CENTER><TD>Month
<SELECT NAME="month">
<OPTION VALUE="ALL" SELECTED>ALL
<OPTION VALUE="1">Jan
<OPTION VALUE="2">Feb
</SELECT>
</TD>
<TD>Day
<SELECT NAME="DAY">
<OPTION VALUE="ALL">ALL
<OPTION VALUE="1">1
<OPTION VALUE="2">2
</SELECT>
</TD>
</TR>
</TABLE>
<P><INPUT TYPE="submit" VALUE="Search">
</FORM>
In my vb program I set up a HttpWebRequest as follows.
I have no experience with HTML or Jscript. Limited experience with VB.
I want to submit a trend_id of "FIRST" with "ALL" months and "ALL" days from
my vb prog.
Dim STE As String = "http://www.another_valid_url"
Dim m_cred As New NetworkCredential("username", "password")
Dim m_Cache As New CredentialCache()
m_Cache.Add(New Uri(STE), "Basic", m_cred)
m_Cache.Add(New Uri(STE), "Digest", m_cred)
m_Cache.Add(New Uri(STE), "NTLM", m_cred)
m_Cache.Add(New Uri(STE), "Kerberos", m_cred)
Dim mm_req As HttpWebRequest = CType(WebRequest.Create(STE),
HttpWebRequest)
mm_req.Credentials = m_Cache
Dim srch As String
srch = "I'm not sure what goes here??"
Dim qq() As Byte = Encoding.ASCII.GetBytes(srch)
mm_req.Method = "POST"
mm_req.ContentLength = qq.Length
mm_req.Timeout = 60000
Dim req_stream As Stream = mm_req.GetRequestStream
req_stream.Write(qq, 0, qq.Length)
req_stream.Close()
Dim mm_resp As HttpWebResponse = CType(mm_req.GetResponse(),
HttpWebResponse)
Dim readStream As New StreamReader(mm_resp.GetResponseStream,
Encoding.ASCII)
Dim ch As String = readStream.ReadToEnd
...
...
readStream.Close()
mm_resp.Close()
I have tried various ways of constructing 'srch' but I keep getting back the
unfilled form. The server doesnt proceed to the url in the Action field of
the form. The username & password are correct.
Thanks anyone
I am trying to fill out a form on a web page and submit the form data to the
web server , all from within my vb program.
The html sorce ( reduced for this post is)
<FORM ACTION="a_valid_url.cfm" METHOD="POST">
<BR>
<P>Trend
<SELECT NAME="trend_id">
<OPTION VALUE="ALL;ALL">ALL
<OPTION VALUE="FIRST;abc">First
<OPTION VALUE="SECOND;abc">Second
</SELECT>
<P>
<TABLE WIDTH=400>
<TR ALIGN=CENTER><TD>Month
<SELECT NAME="month">
<OPTION VALUE="ALL" SELECTED>ALL
<OPTION VALUE="1">Jan
<OPTION VALUE="2">Feb
</SELECT>
</TD>
<TD>Day
<SELECT NAME="DAY">
<OPTION VALUE="ALL">ALL
<OPTION VALUE="1">1
<OPTION VALUE="2">2
</SELECT>
</TD>
</TR>
</TABLE>
<P><INPUT TYPE="submit" VALUE="Search">
</FORM>
In my vb program I set up a HttpWebRequest as follows.
I have no experience with HTML or Jscript. Limited experience with VB.
I want to submit a trend_id of "FIRST" with "ALL" months and "ALL" days from
my vb prog.
Dim STE As String = "http://www.another_valid_url"
Dim m_cred As New NetworkCredential("username", "password")
Dim m_Cache As New CredentialCache()
m_Cache.Add(New Uri(STE), "Basic", m_cred)
m_Cache.Add(New Uri(STE), "Digest", m_cred)
m_Cache.Add(New Uri(STE), "NTLM", m_cred)
m_Cache.Add(New Uri(STE), "Kerberos", m_cred)
Dim mm_req As HttpWebRequest = CType(WebRequest.Create(STE),
HttpWebRequest)
mm_req.Credentials = m_Cache
Dim srch As String
srch = "I'm not sure what goes here??"
Dim qq() As Byte = Encoding.ASCII.GetBytes(srch)
mm_req.Method = "POST"
mm_req.ContentLength = qq.Length
mm_req.Timeout = 60000
Dim req_stream As Stream = mm_req.GetRequestStream
req_stream.Write(qq, 0, qq.Length)
req_stream.Close()
Dim mm_resp As HttpWebResponse = CType(mm_req.GetResponse(),
HttpWebResponse)
Dim readStream As New StreamReader(mm_resp.GetResponseStream,
Encoding.ASCII)
Dim ch As String = readStream.ReadToEnd
...
...
readStream.Close()
mm_resp.Close()
I have tried various ways of constructing 'srch' but I keep getting back the
unfilled form. The server doesnt proceed to the url in the Action field of
the form. The username & password are correct.
Thanks anyone