javascript - Button not reachable using the id from "Inspect Element" -
i trying click on button in page able see id when select inspect option on chrome browser. id of button troop_confirm_go
can see below.
<input id="troop_confirm_go" style="margin-bottom: 5px" class="troop_confirm_go btn btn-attack" name="submit" type="submit" onload="this.disabled=false;" value="send attack">
however, when choose view page source on same page, not able see button id in text. therefore, assume reason not able reach button code in order click on it.
here c# code, using .net framework 4.5:
webbrowser _wb; private void pageloaded(object sender, webbrowserdocumentcompletedeventargs e) { if(!iamsurethisisthecorrectpage()) return; var attack = _wb.document.getelementbyid("troop_confirm_go"); // attack null attack.invokemember("click"); // null reference error }
if can see button id inspecting it, shall able click on right ? how can achieve ?
edit: here parent object of button when click on inspect
. might containing information of why cant access button.
<form id="command-data-form" action="/game.php?village=39143&screen=place&action=command&h=3447af68" method="post" onsubmit="this.submit.disabled=true;"> . . . <input id="troop_confirm_go" style="margin-bottom: 5px" class="troop_confirm_go btn btn-attack" name="submit" type="submit" onload="this.disabled=false;" value="saldırı gönder"> <a href="#" id="troop_confirm_train" class="btn btn-img" style="display: none; line-height: 21px"> <img src="https://dstr.innogamescdn.com/8.44.1/28525/graphic/unit/tiny/snob.png" title="" alt="" class=""> misyoner saldırısı ekle </a> </form>
one problem have had before well, , code example, not clear, if button sitting within panel in form, or within control, might useful use findcontrol() on parent container button sits in. here msdn page findcontrol().
another option, might add jquery code click event of button.
this jquery approach should work either dynamically added dom elements or static dom elements, how ever have added button page, function should pick up:
$(function(){ $(document).on('click', '#troop_confirm_go', function(){ $.ajax({ url: '/controller/methodname/', data: null, type: 'post', success: function (ifanyreturneddata) { //your success logic here } }); } };
Comments
Post a Comment