
but I can't.. I want to click this button automatically when I click my button1 in C# project.
Html Codes:
and I write:
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.Document.GetElementById("XOOPS_TOKEN_REQUEST").InvokeMember("click");
}
but this code doesn't work... Help me please..
you can find this finish button when you fill register form in this page:
http://sfj.grigori.org/register.php
Cheers...
Sam HobbsPosted Jan 21, 2012, 8:01 PM
I am still learning C# and .Net and many other things. Vulpes knows more about C# and .Net. I am also experienced with C++. Most of my professional experience was with COBOL, most of which was before Windows existed.
I have used other languages too of course.
Csharp NinjaPosted Jan 21, 2012, 7:23 PM
Sam HobbsPosted Jan 21, 2012, 6:36 PM
Csharp NinjaPosted Jan 21, 2012, 5:55 PM
for example, I want to go to /register.php page on any site homepage when I click button1.. what code should I write in button1 click event.
hey @Vulpes do you understand me? help me pls. thanks
Sam HobbsPosted Jan 21, 2012, 3:05 PM
I don't know what an action is. If you can explain what an action is in terms of HTML then I can probably explain ho to do it but I don't know what iMacros are.
Csharp NinjaPosted Jan 21, 2012, 2:56 PM
for example, we can do that with FORM=ACTION:edituser.php code in iMacros . but I don't know how can I do that with C#. I need it because I will use that code for my URL List. (for every sites)
Sam HobbsPosted Jan 21, 2012, 2:44 PM
webBrowser1.Navigate("http://sfj.grigori.org/edituser.php");
Hopefully it is that simple. It depends on the situation. There will be times when you might need to get all the anchors ("a" tags or elements) in a page, filter them somehow, then show a list to select from. Then when one of them is selected, your program could navigate to the page specified in the href. For example if a page shows some pictures; you could get all the links and then automatically download all links that are for pictures.
Csharp NinjaPosted Jan 21, 2012, 2:26 PM
Edit Account
how can I click this Edit Account button?
how we can go to blablabla.php , blablabla.aspx , blablabla.html pages with c#?
Sam HobbsPosted Jan 21, 2012, 2:08 PM
There are other ways to find elements using the DOM. I would avoid going through all the elements using the all collection if possible. I would try to determine if I can navigate through the hierarchy of elements, but I would have to study the document to determine how to process that document. My code in article is an example of what I mean. You can look at the documentation to quickly determine that HtmlDocument.GetElementsByTagName can be used to get a collection of "input" tags and then you can look for one with a value attribute of "Finish" and a type attribute of "submit".
Csharp NinjaPosted Jan 21, 2012, 1:37 PM
@vulpes thank you very much bro. you are my hero hehehe :) I want to know C# just like you. please suggest me a good source.
Cheers..
VulpesPosted Jan 21, 2012, 9:09 AM
As there's no id or name attribute, I think you'll have to resort to iterating through the elements until you find one with a value attribute of 'Finish'. This code should do that:
}
Sam HobbsPosted Jan 21, 2012, 5:26 AM
When I go to that page, I see a Submit button but not a Finish button. So I am probably not able to tell you what to use but you probably do not want to use XOOPS_TOKEN_REQUEST.
Also, if it were me and I was having problems with the code, I would split the line into two or more lines. In you code, you call GetElementById then you call InvokeMember. If there is a problem with GetElementById then you might never know that there is a problem; your code might simply fail without warning. So you should first check the return value from GetElementById to ensure it works before calling InvokeMember.