The Html code of my click page is :
<input type="submit" id="publishButton-ns" class="ubtn ubtn-block"
name="publish" tabindex="10" value="Publish Post">
I tried this code for clicking:
webBrowser1.Document.GetElementById("publishButton-ns").InvokeMember("click");
but this not found the button.
Are you waiting for the page to load first? You should bind a function in your code to wait for the page to load, them click the button:
EDIT: This only applies when
runat="server"
is set, not applicable in this case but leaving for others just in case, my apologies on missing that in the question.ASP.Net changes the name of elements it renders based on the structure they are in, you can try the following to get the final name of the element:
You can use jQuery and then do something like this $("#publishButton-ns").click();
http://www.jQuery.com/
This may help you.
Try a combination of @adam's suggestion and capitalize
Click
Just tested this and it didn't work with "click" but did with "Click" :)
I'm using .net 4