I have a website to which I need to pass 4 parameters and then extract data programmatically but there is a big problem. The website is built into ASP.NET with FORM inside AJAX. So, I can fill one field programmatically and then I fill second field. There is a need to click a button in order to fill third field so I press button programmatically then. The problem is that when I click the button, the second fill gets empty before calling the button event and causes error.
So is there a way I can sharply fill fields without causing errors?
Take a look at web automation library such as WatiN - this lets you do this kind of interaction.
I agree with Oded and would like to add that as an alternative Selenium RC in combination with NUnit might be an option.
I believe IRobotSoft web scraper can do this kind of work. You will use two form filling actions, and add a Click action between them.
Related
I am quite new to C#. I am creating a Windows Form Application in Visual Studio 2017 and I was wondering how I link one page to another? e.g. clicking on next which will guide the user to the next page. I do not know the exact words for how to explain this but my research as of now has been quite useless.
I would like to know if I need to create another form? or simply add a new item to the existing form.. I am just not sure. Any help would be great thank you.
Sorry if unclear: E.g.
I have a form I am creating, which requires several details which should be on different stages of the app? I am wanting to have a next button which moves the user from the first page where it may have textboxes to a next page (which I will create - depending on how it works) where there may be radioButton questions.
If you want to project the new page in separate dialog or window just create separate form and trigger the open function of the form when next button is clicked.
If you want to project the new page in the same dialog then use tab control in that same form and make some validation to switch to next tab when next button is clicked.
Note: Using tab control is the best idea for your case.
[edit] It is a requirement that the webpage spawn and open in IE and allow user manual interaction after the programmatic actions have completed.[/edit]
I've seen a lot of code examples online about opening webpages or filling in webpage textboxes and getting a return value without ever opening them visibly.
I would like to open a webpage in IE, fill in a few textbox buttons
and then click the submit button and view the results visibly.
I am able to do this with a dll called Selenium, but I do not want to use a 3rd party application and it seems that WebBrowser() should be able to do this?
I can post my failed code examples if that would help.
Thanks.
Maybe this qould fit better as a comment, but I don't have enoigh reputation.
Do you know how HTTP-Forms work?
It would probably be easier to send a HTTP-Request to the target of the form you want to fill, including the parameters you would like to fill into the form.
So you don't need any WebBrowser or similar, just a simple HttpWebRequest object, where you specity the target, the method (very likely POST) and the data you'd like to send.
You can use the webbrowser control in Winforms. It is possible to access every DOM object of the website using the control. No need to open the IE externally.
You just need to specify the webbrowser URL as your link.
Then, fill the textboxes with code,
BrowserID.Document.GetElementById("TextboxID").SetAttribute("Value", "NewVaue")
Also, you can click on the button using InvokeMember("click").
There are lots of stuff using WebBrowser. You can learn it here.
I'm edited my question,
I have a submit button and textbox in Default.aspx page. I'm open two window Default.aspx. I want to input text into textbox and press submit in this window, other window will update textbox real time.
Please help me !
What you are looking for is similar to chat application.
On receiving a value from one client(browser window), you want to send it to another.
Take a look at SignalR is a good option to keep push data to connected clients.
However if you do want to do it yourself for some reason, the most efficient method to build this in asp.net is to use a IHttpAsyncHandler and ajax requests.
Here is a complete working project that implements this, along with ajax.
I am trying to implement a KeyDown event for a textbox in Visual Web Developer. I am using C#. I know how to do this in a windows form but the technique isn't portable to VWD. I want to capture the text in the textbox when the user hits Enter.
Any advice is appreciated.
Regards.
Sounds like you may want to read up a bit on Web forms in general. A quick summary:
Since web pages are all client side, you have to explicitly tell it when to talk to the server where all the major lifting takes place.
So you have the html form tags:
<form>
</form>
and all important text boxes and other form controls go between.
Then you need a submit button which under normal circumstances is the only way to submit the form to the server for processing. (The "enter" key activates the submit key also.). Submission always either reloads the page or causes a move to the next page, depending on the actions specified.
ASP.NET does take care of a lot of page events and such for you. as you have probably noticed by now, though, when you right click a text box and look at the available events, you only have a few, such as "textchanged". This is because anytime you do not actually submit a form to the server, you need AJAX to do a call to the server for you while not reloading the page. the "textchanged" event on a textbox is still going to be AJAX driven - it's just the Microsoft has built it in for you. You will want to look at either jQuery or the ASP.Net AJAX libraries.
You say you want to "store" the result - is it to generate new behavior later on the page? that's AJAX. Is it for longevity while the entire application is worked through? That can wait until the submit.
Actually the textChanged method waits for the Enter key to be hit.
I'm creating a multi-part web form in ASP.NET that uses Panels for the different steps, making only the Panel for the current step visible. On Step 1, I have a drop-down list that uses a Javascript function to reconfigure some of the fields in the same Panel via "onchange". Obviously, since the client-side script is only affecting the DOM, when I go to Step 2 and then back up to Step 1, the fields in Step 1 are back to their orignal configuration even though the same drop-down choice is selected.
What is a good method for storing the visual state of the Panels between steps? I considered calling the drop-down's onchange function on page load, but that seemed clunky. Thanks!
--
Thanks for the quick answers - I think I'll try out the Wizard, but the AJAX solution also sounds like fun.
You might consider an ASP.Net Wizard control for this- it will automate a lot of what you're trying to do.
I suggest you to use the MultiView control, which is let's say semantically more appropiate. And then store this data in ViewState. I have written something similar and it rocks.
I think your best bet is to maintain all of your state in one place, or don't maintain any state at all. The main problem you're having is synchronizing your client-side state with your server-side state.
Try showing/hiding your panels with javascript instead of posting back, if possible. If not, use some ajax to update values on the server-side as soon as they are selected, rather than when you click the next/previous button.
Otherwise, you could use something like ASP.Net Ajax Toolkit Tabs to help with transitions.
Hope that helps!