当前位置:编程学习 > C#/ASP.NET >>

请教下怎么用webbrowser模拟点击这个页面的按钮

请教下怎么用webbrowser模拟点击这个页面的"断开"按钮,我试了论坛上其他类似问题的方法都不行,谢谢指教了。
页面图片如下:
页面代码如下,开头那段而已

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="refresh" content="10">
<title></title>
<link href="style.css" rel="stylesheet" type="text/css">
<script  type="text/javascript">
function chang_btn_name()
{
if (form1.con_dis_stat.value=='1')
{
form1.disconnect_connect.value=' 断 开 ';
form1.input_value.value="0";
}
else
{
form1.disconnect_connect.value=' 连 接 ';
form1.input_value.value="1";
}

if(status_form.wirel_bas_work_mode.value=="WDS") //wds
{
hide_connect_div.style.display="none";
hide_ssid_div.style.display="none";
}
}
function check()
{
form1.click_value.value='1';
if(form1.con_dis_stat.value=='1')
{
form1.input_value.value="0";
//alert(form1.input_value.value);
}
else
{
form1.input_value.value="1";
// alert(form1.input_value.value);
}
window.top.document.all.hiddenFrame.src="diagnosis.htm";
}
</script>
</head>

<body onLoad="chang_btn_name();">
<table width="610" border="0" class="menu_td">
<form name="status_form">
<input name="wirel_bas_work_mode" type="hidden" value="AP">
</form>
  <tr>
    <td height="15"><table width="570"  border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td height="10" width="153" class="item_left" ><span class="menu_string_display">
WAN 状态</span></td>
                <td width="388"> </td>
              </tr>
              <tr>
                <td height="1" colspan="2" class="subtitle_underbar"></td>
              </tr>
              <tr>
                <td height="10" colspan="2"></td>
              </tr>
            </table>      <table width="570" border="0" cellpadding="0" cellspacing="0" class="content_table">
          
                <tr>
                  <td width="124" class="item_title"><span class="item_title_string"> 
 连接方式</span></td>
                  <td width="459" class="item_center"><div align="left"><span class="item_string">PPPoE</span></div></td>
                </tr>
                <tr>
                  <td class="item_title"><span class="item_title_string"> 
 MAC地址</span></td>
                  <td class="item_center"><div align="left"><span class="item_string">08-10-74-0f-a4-7d</span></div></td>
                </tr>
                <tr>
                  <td class="item_title"><span class="item_title_string">  IP    地址</span></td>
                  <td class="item_center"><div align="left"><span class="item_string">202.105.159.113</span></div></td>
                </tr>
                <tr>
                  <td class="item_title"><span class="item_title_string"> 
 子网掩码</span></td>
                  <td class="item_center"><div align="left"><span class="item_string">255.255.255.255</span></div></td>
                </tr>
                <tr>
                  <td class="item_title"><span class="item_title_string"> 
 默认网关</span></td>
                  <td class="item_center"><div align="left"><span class="item_string">202.105.159.113</span></div></td>
                </tr>
                <tr>
                  <td class="item_title"><span class="item_title_string"> 
 首选DNS</span></td>
                  <td class="item_center"><div align="left"><span class="item_string">192.168.0.1</span></div></td>
                </tr>
                <tr>
                  <td class="item_title"><span class="item_title_string"> 
 备份DNS</span></td>
                  <td class="item_center"><div align="left"><span class="item_string">202.96.134.133</span></div></td>
                </tr>
                
                <tr>
                  <td class="item_title"><span class="item_title_string"> 
 VPN透传</span></td>
                  <td class="item_center" ><div align="left"><span class="item_string">开启</span></div></td>
                </tr>
                <tr>
                  <td height="33" colspan="2" class="item_center"><span class="item_title_string">
</span>
                    <table width="100%" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <td width="72%" height="21"> <div align="center"><span class="item_title_string">
本页面每 10 秒刷新一次 </span></div></td>
                        <form name="form1" action="wan_connect_disconnect.cgi" method="post">
<td width="28%"><input type="submit" name="disconnect_connect" value=" 连 接 " onClick="check();"><input type="hidden" name="click_value" value="999"><input type="hidden" name="input_value" value="999"><input type="hidden" name="con_dis_stat" value="1"></td>
</form>
                      </tr>
                    </table></td>
                </tr>

      </table>            <table width="100%"  border="0" cellpadding="0" cellspacing="0" class="table_space">


我现在这样子不行,代码如下:

public void changeIp()
        {
            object boxDoc = null;
            HtmlDocument hDoc2 = null;

            boxDoc = wb.Document;
            hDoc2 = (HtmlDocument)boxDoc;
            HtmlElementCollection hall2 = hDoc2.All;

            HtmlElementCollection hCols = hall2.GetElementsByName("con_dis_stat");
            foreach (HtmlElement hCol in hCols)
                hCol.InvokeMember("onChick");
            //hCol.InvokeMember("onClick");
        }
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,