我有两个工程,一个是windows的应用程序。一个是web应用程序。我使用AxWebBrowser控件在一个windows form里打开一个web页面。我怎么才能从windows的form里把值传到web页面里,谢谢。

解决方案 »

  1.   

    seeMicrosoft Web Browser Automation using C#
    http://www.codeproject.com/csharp/mshtml_automation.asp?df=100&forumid=26186&exp=0&select=1508825
      

  2.   

    我以你登录CSDN为例往WEBBROWSER控件中输入用户名和密码:
    你先在FORMLOAD时:
    object o=null;
    string strUrl="http://passport.csdn.net/UserLogin.aspx";//"http://passport.csdn.net/member/UserLogin.aspx";
    axWebBrowser1.Navigate(strUrl,ref o,ref o,ref o,ref o);
    BUTTONCLICK:
    if(axWebBrowser1.ReadyState!=SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
    {
    MessageBox.Show("文档还未加载完成,请稍候再试");
    return;
    }
    HTMLDocument doc=(HTMLDocument)axWebBrowser1.Document;
    mshtml.IHTMLDocument2 doc1=(mshtml.IHTMLDocument2)axWebBrowser1.Document;
    IHTMLInputElement inp=null;
    IHTMLElement ihe=null;
    inp=(IHTMLInputElement)doc.all.item("CSDNUserLogin:tb_UserName",0);
    if(inp==null)
    {
    MessageBox.Show("无法得到网页元素,登录失败,请重新试试");
    return;
    }
    inp.value=txtUser.Text.Trim();
    inp=(IHTMLInputElement)doc.all.item("CSDNUserLogin:tb_Password",0);
    if(inp==null)
    {
    MessageBox.Show("无法得到网页元素,登录失败,请重新试试");
    return;
    }
    inp.value=txtPsw.Text.Trim();
      

  3.   

    谢谢两位,可是似乎不是我要的答案。我要做的是把一个windows form上的数据传递到browser控件所打开的页面里。谢谢