2014-04-06 2 views
2

1.HttpWebRequest + HttpWebResponse 클래스에서 DropDownList로 선택하는 방법 내가에서는 StreamReader에 필요한 모든 정보를 저장 + HttpWebRespons (DDL에서 선택 옵션) 2.send HttpWebRequest를 "ex.asps".로그인 한 다음 페이지로 이동을 위해 HttpWebRequest를

1. 나는 모든 정보를 모두 볼 수있다. 2. 나는 dll (Id, 모든 옵션, 값, 이름)을 볼 수 있지만 올바른 옵션을 선택하는 방법을 찾지 못한다. 하나, 너트 모든 하나씩 하나씩 선택하고 데이터를 저장 trow 갈 필요가 너트. 예는 : 4 사용자와 하나 하나가 (나이, ID ...) 같은 데이터를 자신이 가진 DDL 난 단지 1 명의 사용자를 저장할 수 있습니다처럼하지만 난이 내 코드

입니다 새로운 데이터

를 얻기 위해 DDL을 변경해야 나는이 문제를 해결할 수 있다고 PostString에 일부 데이터를 전달하는 방법이 알고 있기 때문에

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"); 
for (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 i can see that data is not changed 


            if (outString == null) 
            { 
             LogOut(); 
            } 

           } 
+0

명 내 질문을 상승하지 마십시오! –

+0

매우 지저분 해 보였기 때문에 질문이 다운 그레이드되었습니다. 그것을 파헤치는 것은 어렵습니다. 약간의 노력을 투자하고 가독성을 향상시켜야합니다. 그렇다면 사람들이 당신의 질문을 읽고 답을 줄 가능성이 더 큽니다. – honk

+0

내 원산지 질문이 다르게 보입니다. 위에서 몇 줄을 뿌리지 않습니다. 편집을 시도하지만 편집 모드에서 전체 질문을 볼 수는 있지만 여기서는 처음 2 줄을 볼 수 없습니다 ..... –

답변

-1
$("#ctl00_PlaceHolderMain_AccountsDDL_ddlAccounts")[0].selectedIndex = 0;//Here we select the index 
__doPostBack('ctl00_PlaceHolderMain_AccountsDDL_ddlAccounts','') // here the postback 
관련 문제