Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在HttpWebRequest中选择DropDownList_C#_Asp.net_Html Agility Pack - Fatal编程技术网

C# 如何在HttpWebRequest中选择DropDownList

C# 如何在HttpWebRequest中选择DropDownList,c#,asp.net,html-agility-pack,C#,Asp.net,Html Agility Pack,1.登录时使用HttpWebRequest+HttpWebResponse,然后转到“ex.asps”页面 2.发送HttpWebRequest(使用ddl中的select选项)+HttpWebResponse以保存我需要StreamReader的所有信息 1.我成功了我看到了所有信息所有工作 2.我看到了dll(Id、所有选项、值、名称),但我找不到选择正确选项的方法我只能看到并保存第一个选项,我需要逐个选择所有ddl并保存数据。 例如:像有4个用户的ddl,每个用户都有自己的数据,比如(年龄

1.登录时使用HttpWebRequest+HttpWebResponse,然后转到“ex.asps”页面 2.发送HttpWebRequest(使用ddl中的select选项)+HttpWebResponse以保存我需要StreamReader的所有信息

1.我成功了我看到了所有信息所有工作 2.我看到了dll(Id、所有选项、值、名称),但我找不到选择正确选项的方法我只能看到并保存第一个选项,我需要逐个选择所有ddl并保存数据。 例如:像有4个用户的ddl,每个用户都有自己的数据,比如(年龄、ID…) 我只能保存1个用户,但我需要更改ddl以获取新数据

这是我的密码

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();
                                    }

                                } 
if(IsLogin)
{
HttpWebResponse RedirectResponse=RedirectToUrl(“https://services.test.com/Pages/Trans.aspx");
streamResponse=RedirectResponse.GetResponseStream();
StreamReader streamRead=新的StreamReader(streamResponse);
outString=streamRead.ReadToEnd();
System.Collections.ArrayList strAccountList=GetListByID(“ctl00\u占位符主\u账户SDDL\u账户”);
对于(int intAccountCount=0;intAccountCount
大家请不要轻视我的问题,因为我知道有一种方法可以将一些数据传递到PostString来解决这个问题!!!您的问题被降级,因为它看起来很凌乱。很难深入研究。您应该投入一些精力并提高可读性。然后人们更可能会阅读您的问题并给出答案n回答。我的原始问题看起来不一样。它没有从顶部播下几行。我尝试编辑它,但在编辑模式下,我看到了完整的问题,但在这里我看不到前两行…..请研究以改进格式。人们请不要把我的问题放低,因为我知道有一种方法可以将一些数据传递到PostString,从而我解决了这个问题!!!你的问题被降级了,因为它看起来很凌乱。很难理解它。你应该投入一些精力,提高可读性。然后人们更可能会阅读你的问题并给出答案。我的原始问题看起来不同,它没有从顶部开始,我尝试编辑它,但在编辑模式下,我看到了f这是一个完整的问题,但我看不到前两行……请研究以改进格式。
$("#ctl00_PlaceHolderMain_AccountsDDL_ddlAccounts")[0].selectedIndex = 0;//Here we select the index
__doPostBack('ctl00_PlaceHolderMain_AccountsDDL_ddlAccounts','') // here the postback