I want to create a program which will automatically fill in certain blank spaces in multiple HTML pages.
For instance I have to go through this kind of flow
Log in page where I used GetElementById("").InnerText to fill in the blanks and GetElementById("").InvokeMember("click") to progress to the next page.
Second page requires me to navigate to a different page hence I used webBrowser1.Nagivate("").
The whole program mainly revolves around these two processes, navigation and auto filling. Currently, I am stuck when the webform navigates to the next webpage but is unable to read ID for fields.
Is there any way to go about it? Or any links which might be helpful?
Related
I created an ASP .NET Web Forms application from Visual Studio 2017 creator with C# as a language. I did minimum changes to the template and my web page loads a 3D image, takes a few additional parameters via Buttons and Text fields, sends it for processing to server. There it lands in a directory where it is processed by a commercial program, independent of Visual Studio, which initially writes to a directory with an image ID (say ABCD) and into a directory with an image taking date (say 20170629), after some processing, 2-5 minutes, it writes the results of the analysis into a new folder with a current date (say 20171031) into a text file where the name consists of 15 digits code and a known extension (say 123456789012345.txt). It is within Java Derby database, for which I did not find any connectors from .NET.
The web page meanwhile shows the summary of data sent. What I got working is the Button which while pressed checks if the mentioned directory (20171031) is already created shows the asp:UpdatePanel with progress (1/3 stages passed, 2/3 stages passed etc.) and when the file 123456789012345.txt is ready it gets the data from it and on the server side it calculates some values and displays them. Because of waiting there are several public async Task and public async Task methods to search for file appearance.
I wanted to avoid manual pressing of the Button, so that the processing stage is shown and once the file 123456789012345.txt is ready the values is calculated. For the moment I tried various ways, but without success. I prefer to avoid reloading the whole page every 30 seconds, because the user may get confused.
asp:UpdatePanel, as far as I understand needs pressing of the Button or some other interaction from the user side. If I use in aspx.cs file in Load_Page method the UpdatePanelName.Update(); for whatever reason the panel is not updated. Due to the use of await CalculateImageAsync(), the only way I found to have it in Page__Load is to have it as protected async void Page_Load(object sender, EventArg e) , but when page is loaded, it never loads. Anything else needs user interaction, which I want to avoid. I got stuck...
I am new in ASP .NET and C#, so maybe I do something wrong or miss some nice .NET method. I would be obliged for help. I have seen pages doing the job like I want, for example in the journals, where you submit a DOCX file where it is converted to PDF - once you submit it after some time you get a page with resulting PDF.
Regards, Marcin
Is such a thing possible? I have a search page and the user clicks a link to edit a document and it takes them to another page.
The user then hits the browser's back button i want to take them back to the results that they left off on so they don't have to search again.
EDIT: The search works as the user enters in parameters and it goes out to the database and returns results in a type of search result viewmodel. That viewmodel is parsed out to a table format and shown on the screen. Each row has certain bits of information tied to it like the primary key and other things that the user can see.
Once the user hits edit it uses the primary key to go back to the database to get the remaining data for that row and shows them a form on screen. If the user hits the back button on the browser I want to take them back to the result set that they just viewed without having to redo the search.
The way we have it setup is when the user hits back it goes to the index method that just does a new search page.
You can do this using the HTML5 History API. For instance, when the search returns its result you can use:
history.replaceState(..);
to modify the current browser history entry. It isn't compatible with some older browsers though, so if you have to support those, this may not work properly - or you'll have to find a workaround.
There exists a couple of 3rd party angular modules out there that wraps the history API, but it should work just fine on it's own.
A way I've done this is by using a controller extension method to get the page's search state from session. I'm sure there is a better way to do this in Angular though.
I have an ASP.Net web page that displays various chunks of data based on a user's search string. In this web page I'm using a <Panel> tag because I need to have a vertical scrollbar that displays when needed to display all of the data.
I've thought about defining an HTML page (in code behind, with all the tags and data included), and displaying that inside a <div>, inside the <Panel>.
I've also explored the possibility of displaying an ASP.Net web page with the data/tags/etc. and placing each page in its own <Iframe> element. I'm afraid that this solution would be slow to load (as compaired to the HTML method described above) especially when there's 100's of individual pages to be loaded.
My question is what's the best way to display N number of individual pages of data and have a vertical scrollbar when there's a need?
Displaying various data pieces on ASP.NET pages is a big subject, I suppose, and many methods can be used, including the ones you've mentioned.
How about making use of Dynamic Data framework .NET v2,3,4. The most powerful is the latest one of course.
Then you don't need to create 100's of individual pages, just onthe fly redirect using metatable names used in your model/context. All you data will also be wonderfully linked where appropriate. Also need to carefully design you model based on however your data needs be presented. The controls for that could be GridView or other, but all done on server side.
I'm working on a page that has several server side dropdown lists, one with 500 items. Based on what's selected, I show/hide other page elements during postback (I only bind the data on initial load). The customer opens this page a lot and I don't want them pulling the 500 items down every time they open it. Currently, it takes about 2 to 5 seconds for the page to render. I've started to migrate to a fully javascript/jquery version of the page but want your opinion because I'm not loving the new version.
Is there a way to make this page faster and limit pulling down all 500 items every time?
Note: Some users will want to enter the dental procedure code directly. Others will need to do a look up.
We work on a system where a user's name can be selected from a dropdown list and then user information is displayed below. There are approximately 600 users and one of the stakeholder requirements was that the users had to be selectable in a dropdown list - the stakeholders felt that non-technical users better "understood" how to use a dropdown list.
Our performance for loading the dropdown list is very good. We do the following:
Load the page as quickly as possible but DO NOT load the dropdown list
On page load, display a loading indicator and then immediately fetch the data for the dropdown list
We get the data by calling a webservice using jQuery that returns ONLY usernames and IDs and data is returned in JSON format
The query that requests the data is cached on the server for future requests
The resulting JSON object is used to populate the dropdown list
Hide the loading indicator and you're done
The above occurs extremely quickly and makes for a very pleasant user experience.
If anything, try very hard to do the following:
Avoid postbacks even if you're using an Update Panel - these will kill performance if you have a large viewstate
Only return the absolute bare minimum of data that you need to populate the dropdown list
Don't access any data that isn't immediately necessary. Get the page loaded as quickly as possible and then fetch the remaining information while the user is reading the page
When adding large amounts of data to a page, milliseconds count. Anything you can do to reduce calls for data (and the subsequent adding of that data to the page) will drastically improve the user experience.
It's been a while since I've done asp.net but remember something from the Ajax control toolkit that is like a set of filtering drop downs that group items so you don't have to get the full list.
For example if you're getting a list of all cars, you could have the first drop down as Manufacturer, which when selected activates a second drop down with their range of Models. It limits the ammount of data you have to load at once.
A dropdown list is not a good container for 500 items because the looong list looks ugly and it's hard to locate an item. You can change it to a table-like control(from server view, a gridview or a repeater) with paging function(e.g. display 20 items per page), also you can add some textboxes above the table, users can quickly locate an item by typing some keywords. After that, put the table in a update panel to make the page partially updated when clicking some button.
Anything you can do on the page that doesn't require the entire page to change can be made AJAX-y by enclosing it in an UpdatePanel. UpdatePanels and ScriptManagers allow ASP.NET pages to perform partial postbacks using AJAX, which will speed up anything but a full page reload by drastically reducing the number of data that has to come across.
Other performance tips/tricks:
If you're using an ORM, or generic queries, to pull in records, try to pull the minimum amount of data you need to show the results. The more data that has to come from the DB and be digested into the viewmodel, the slower the back-end will be.
Avoid nested MultiViews. Multiviews are great for organizing a lot of data in a "tabbed" fashion, but behind the scenes a MultiView is rendered as a series of divs with CSS to hide/show them. That means that EVERY tab of a MultiView must be rendered on the initial page load. When multiple MultiViews are nested as Views of other MultiViews, the problem is compounded. You can avoid this by using the codebehind to dynamically select and insert the proper control into the page, or by using other code to detect whether the View that this control corresponds to is the currently-selected view, and skip any heavy lifting of data retrieval/processing that would otherwise happen. You may combine either approach with some AJAX components.
I'd start with correctly indexing the database.
One way to speed things up would be to get rid of the postbacks. Showing/hiding page elements is a client-side operation and doesn't require a postback. If you're using jQuery already, you can .show() and .hide() any element on the page.
This doesn't necessarily address the performance of the initial page load, but would improve the performance of the overall user experience when interacting with the page.
For the initial load, perhaps break out various data-bound elements into AJAX calls that happen behind the scenes after the initial page markup loads? I'm kind of shooting in the dark here without knowing a whole lot about the page, but it's worth a try. Maybe load the basic markup without the data in the lists, then on $(document).ready() make an AJAX call to a server-side handler which returns the elements for the first menu. Then, when each menu is selected, fetch the elements for the next menu in the same manner.
The overall load time would be roughly the same (maybe even a fraction of a second longer), but the UI would fully render in the meantime and you'd be using the time the user spends looking at the page and starting to interact with it, a few precious seconds, to load the rest.
Edit: In response to one of your comments above on the question, maybe you can use the jQuery UI Autocomplete to improve the user experience a little? Do the users necessarily want to select the codes from a list, or would it be easier for them to start typing the code and narrow down to the correct one? From a data-entry perspective, avoiding mouse usage is often a good idea.
Using javascript or any of client script is not an solution because the client browser may have javascript disabled...
I would suggest you these opmization,
Optimise database query if your table containing 500 records and
is not frequently have insert/update operations then create unclustered indexes.
Cache the data if not changes frequently.
Create stored procedures improves query results because it's being precompiled query and prevents sql injection attacks.
In my ASP.NET WebForms application, I have a WebForm that contains an UpdatePanel and multiple views used for a wizard like interface.
At the end of the wizard, the user has an option of moving to another page by clicking a button. This new web page needs about 5 values from controls in the previous page.
What is the simplest way to do this? (Edit: ONLY using an HTTP POST with data - this is a requirement as I would use database/session otherwise)
I tried using cross-page posting with no luck, possibly because of my update panel and multiple views?
I tried using Server.Transfer, but this also breaks because of the update panel.
Important:
Data has to be sent via HTTP POST - The data can't be stored anywhere
The scenario can't be changed. I can't put everything on the same page
The simplest way to do this is by putting those values in the session object.
You could make a class that describes the data that you need to display on the redirected page. Instatiate a new instance of that at the time the user is filling out the wizard data, populate the new classes' object with the information you need, then add it to the session in the button_Click event before page redirection. On the page you are redirected to, grab the Session object, put it into a variable and extract the data you need.
I recommend you combine all the relevant pages into one; hiding panels that are not in play. ASP.NET will maintain the values of all the controls for you from post to post. The Viewstate was designed for sceneries like you describe. To keep to Viewstate size to a minimum, make sure you fill lookup values for drop-down controls in their "Init" methods.
You don't want to use the session state. The last thing you want is for the users to loose their data from previous pages because they took too long to answer.
If they're moving to another page in the solution, you have a few options.
ViewState - The ViewState is sent with the page delivery. It resides in the HTML, but is encrypted so no one can see the information. Depending on the size of the information, your page size could get rather large.
Session - This puts the information client-side via cookies.
Query String - Using the URI. This should only be used if it's non-sensitive information and if you don't want a user to be able to link back to the same action again.