c# - How to select from DropDownList in HttpWebRequest -
1.httpwebrequest+httpwebresponse login go page "ex.asps" 2.send httpwebrequest(with select option ddl)+httpwebrespons save info need streamreader.
1.i succeed see info work 2.i see dll(id, options,values,name) cant find out way select right option can see , save first one,nut need go trow ddl select 1 one , save data. ex: ddl 4 user , each 1 have own data (age,id...) can save 1 user need change ddl new data
this code
if (islogin) { httpwebresponse redirectresponse = redirecttourl("https://services.test.com/pages/trans.aspx"); stream streamresponse = redirectresponse.getresponsestream(); streamreader streamread = new streamreader(streamresponse); outstring = streamread.readtoend(); system.collections.arraylist straccountlist = getlistbyid("ctl00_placeholdermain_accountsddl_ddlaccounts"); (int intaccountcount = 0; intaccountcount < straccountlist.count; intaccountcount++) { string[] stracctlist = straccountlist[intaccountcount].tostring().split('\t'); string straccountnumber = stracctlist[0]; poststring += "__eventvalidation=" + getvaluebyid(logininfo, "__eventvalidation") + "&"; poststring += "ctl00$placeholdermain$accountsddl$ddlaccounts=" + straccountnumber + "&"; httpwebrequest postrequest = (httpwebrequest)webrequest.create("https://services.test.com/currentaccount/pages/current.aspx"); postrequest.cookiecontainer = new cookiecontainer(); postrequest.cookiecontainer = _cookies; postrequest.method = webrequestmethods.http.post; postrequest.useragent = "mozilla/4.0 (compatible; msie 7.0; windows nt 5.1)"; postrequest.allowwritestreambuffering = false; postrequest.protocolversion = httpversion.version11; postrequest.allowautoredirect = false; postrequest.contenttype = "application/x-www-form-urlencoded"; byte[] bytearray = encoding.ascii.getbytes(poststring); postrequest.contentlength = bytearray.length; stream newstream = postrequest.getrequeststream(); newstream.write(bytearray, 0, bytearray.length); newstream.close(); httpwebresponse postresponse = (httpwebresponse)postrequest.getresponse(); outstring = ""; stream streamresponseloginform = postresponse.getresponsestream(); streamreader streamreadloginform = new streamreader(streamresponseloginform); outstring = streamreadloginform.readtoend();//here can see data not changed if (outstring == null) { logout(); } }
$("#ctl00_placeholdermain_accountsddl_ddlaccounts")[0].selectedindex = 0;//here select index __dopostback('ctl00_placeholdermain_accountsddl_ddlaccounts','') // here postback
Comments
Post a Comment