我需要使用" HTTP Post"使用WebClient将某些数据发布到特定的URL。 我有一些问题要将值传递给输入类型" Radio"。
部分网络代码:
<li class='cua_cols'>NIF a seleccionar<br />
<big><strong>A********</strong></big>
</li>
<li><label for='wNif'><input type='hidden' id='wNif' name='wNif' value='A********' /></label></li>
<li class='dos_cols'>
<label for='TIPONIF0'>
que actúa como
<br />
</label>
<b>Operador </b><input type='radio' id='TIPONIF0' name='TIPONIF' value='OP' checked = 'checked' />
<b>Autorizado </b><input type='radio' id='TIPONIF1' name='TIPONIF' value='AU' />
</li>
<li class='ancho_99'> </li><li class='cua_cols'>
<label for='wNifAut'>
NIF relacionado=
<br />
<input type='text' name='wNifAut' id='wNifAut' value='B********' maxlength='17' size='19' onkeypress='javascript:if (event.keyCode == 13) return false; ' onclick='' />
</label></li>
<li class='cua_cols'>
<label for='TIPONIF_SOL0'>
que actúa como
<br />
</label>
<b>Operador </b><input type='radio' id='TIPONIF_SOL0' name='TIPONIF_SOL' value='OP' />
<b>Autorizado </b><input type='radio' id='TIPONIF_SOL1' name='TIPONIF_SOL' value='AU' checked = 'checked' />
</li>
第一次下一个代码正常工作,但今天只对wNifAut值进行了设置。
Dim requestData As New NameValueCollection()
requestData.Add("wNifAut", mnoCIF)
requestData.Add("TIPONIF1", "true")
requestData.Add("TIPONIF_SOL0", "true")
requestData.Add("Buscar", "Click")
Dim request As Byte() = myWebClient.UploadValues(msStrURL, "POST", requestData)
msHTMLString = Encoding.UTF8.GetString(request)
答案 0 :(得分:0)
OP解决方案。
页面的源代码也包含这个:
<label for="VEZ"><input name="VEZ" id="VEZ" type="hidden" value=""></label>
<div class="AEAT_bloque_botones">
<input name="Buscar" class="AEAT_boton" accesskey="A" onkeypress='javascript:enviarDatos("BUSCAR1");' onclick='javascript:enviarDatos("BUSCAR1");' type="button" value="Buscar">
<input name="Limpiar" class="AEAT_boton" accesskey="D" onkeypress='javascript:resetear(getVarDom("Query"));' onclick='javascript:resetear(getVarDom("Query"));' type="button" value="Limpiar">
</div>
<script type="text/javascript">
function enviarDatos(opcion) { getVarDom("Query").VEZ.value=opcion;
getVarDom("Query").submit(); }
</script>
我在代码中更改了一些行:
Dim requestData As New NameValueCollection()
requestData.Add("wNif", mnoCIFComp)
requestData.Add("wNifAut", mnoCIF)
requestData.Add("TIPONIF", "AU")
requestData.Add("TIPONIF_SOL", "OP")
requestData.Add("VEZ", "BUSCAR1")
Dim request As Byte() = myWebClient.UploadValues(msStrURL, "POST", requestData)
msHTMLString = Encoding.UTF8.GetString(request)
重要变更
1) I indicated the input radio values with pair (name - value) instead of (id - 'true')
2) I assigned the value "BUSCAR1" to the hidden label, to simulated the JavaScript function.
3) In this case I had to assign the company cif.