WebBrowser.DocumentText Not Updating - vb.net

I am loading a web page into webbrowser control and after waiting for the document to load, I am reading in the .documenttext to retrieve various bits of data.
I then want to test if the data on the web page has changed (it's a dynamic update) and if so, I retrieve the updated data.
The problem is that .document.text is not updating, either after a dynamic update to the page or if I physically navigate within the browser control to another page.
When I loop through all elements using '.getelementsbytagname' I get the up to date web page data, but obviously want to avoid this if the data hasn't changed. So '.document' updates but '.documenttext' doesn't.
So the '.documenttext' doesn't get updated when the web page changes. Is there a way to force this update? Or a better/simpler way to check for a page update?
.refresh() does work, but I don't want to be reloading the document when it's already up to date.
Dim pp = Uni.wbUni.DocumentText
If pp = GlobalVariables.unistr Then
Console.WriteLine("no change" & Now())
Exit Sub
End If
Console.WriteLine("change" & Now())
GlobalVariables.unistr = Uni.wbUni.DocumentText
So from the above pp never actually updates

Dim pp = Uni.wbUni.Document.Body.InnerText

Related

How can I make a form instance open a specific record on creation?

I'm trying to optimize the performance of my access frontend. One of the problems I'm stumbling on is how to set a multi-window form to open immediately to a specific record, because at the moment it queries everything twice.
Essentially, I allow my users to open multiple instances of a form. That way, a user can compare multiple records by placing the windows of those forms side by side.
At the moment, my code looks like this:
Set frm = New Form_Name
frm.RecordSource = "select * from Table where id = " & ID 'ID is a variable passed to the method
I'm pretty sure back then this question was one of the building blocks I relied on.
The problem is that on the first line, access already entirely opens the form and does everything the form does when opening, such as Form_Open, Form_Current, and loading subforms. Then, when I set the recordsource, it does all (or most) of that again, which significantly slows down the process of opening the form.
Here are some of the things I've tried:
Changing the Form_Current to recognize that it's being "used" twice and only actually run the code once. The problem is that the code is already very optimized and doesn't seem to be the bottleneck, so this doesn't seem to do much. Actually opening the form seems to be the bottleneck.
Trying to change the properties of the original form so that it opens the specific record I need, but I can't seem to change the properties without it opening the form.
Looking for a way to supply arguments to the form. That doesn't seem to be supported in VBA.
One other idea that popped into my mind was creating a variable in vba with the ID of the record, setting recordsource in the form properties to fetch that variable, but then, when I would open another form and change that ID, the form
I realize that I can do this with DoCmd.OpenForm, but that doesn't give me the option to open multiple instances of the same form.
How can I achieve this? This would mean a significant performance improvement.
OK, so I actually wanted to ask this question. But just before I hit the submit button, I had an idea...
Here's the idea: you set a global variable in VBA, which you then access in the form filter command. In my case I just added Public OpeningID As Long at the top of my VBA module. Then I create a function to get that value:
Public Function getFormID() As Long
getFormID = OpeningID
End Function
Then, in the form, you can set the filter criteria as ID = getFormID(). And then when you open the form instance, you do it like this:
OpeningID = ID
Set frm = New Form_Name
OpenindID = 0 'reset this to make sure that if it's being accessed when it shouldn't, it generates a clear error
The only problem is what happens when you refresh the form, as that will call the method again. When you refresh the form via VBA, you can set the OpeningID beforehand, and to avoid users refreshing the form, you can add this to your form (don't forget to turn on Key Previews in the form settings):
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF5 Then KeyCode = 0
End Sub
Bang. Forms open almost twice as fast. Awesome.

How can I redirect to the same page multiple times with a different query string?

I have a page that contains a table with a list of data and an icon (on each row) which redirects the user to a new aspx page with a queryString and does some custom logic to then download the file. The user has asked that we make a "download all" button so they don't have to go through and manually click every icon in every row.
My code is close, I feel, but it will hang after the first file is downloaded and will never progress further.
Here is the code I have so far
Protected Sub ibDownloadAll_Click(sender As Object, e As ImageClickEventArgs)
'Get Parameters
'Run stored procedure to get the query string we're going to use
'Fill DataSet
For Each myItem As DataRow In ds.Tables(0).Rows
Response.Redirect("redirectPage?ID=" &myItem.Item("ID")) 'Gets stuck after here
Next
End Sub
I realized if I added the second parameter (Indicates whether execution of the
current page should terminate)
Response.Redirect("redirectPage?ID=" &myItem.Item("ID"), False)
Then it would make it to the end of the function, running through the loop as expected, but then only outputting/downloading the last file.
Is there something I'm missing or an alternative that can be used to effectively redirect multiple times? Unfortunately with the framework I'm using I'm not able to use Response.Write and put custom scripts in that way, nor can I really change the page that we are redirecting to.
You can't redirect to multiple pages (a redirect close the request) and you also can't send multiple files. Your only option would be to have a request that zip all the files together. You can do this with System.IO.Compression.ZipArchive. You don't need to save the zip on disk, you could just send the memory stream.

PCOMM gettext is pulling invisible information

I've had a randomly recurring issue where I can use gettext to pull information just fine from a page on a PCOMM (IBM Personal Communicator) screen, then when I go to the next screen it will pull that SAME information, despite appearing visually blank.
I can't paste screenshots for InfoSec reasons... But here's the gist:
Dim ps As New AutPS
Dim oia As New AutOIA
Page 1: ps.GetText(15,31,7) = 1800.00 (I can see this value on the screen.)
Go to next page, wait for oia.InputInhibited = 0 And ps.Ready
Page 2: ps.GetText(15,31,7) = 1800.00 (Screen in this position appears blank.)
This issue is not isolated, and is repeatable with a specific account number.
Found a solution!
The key lies with using the ps.autECLFieldList. This object can detect when a given field (located using FindFieldByRowCol) is displayed or not, so when used in tandem with our getText, we can make sure that we're only retrieving information from a visible field.
Dim fl As Object = ps.autECLFieldList
fl.refresh() 'Good practice to make sure the Field List is up to date
If fl.FindFieldByRowCol(15, 31).display Then
Amount = ps.GetText(15, 31, 7)
End If

Generate dynamic web pages and urls in vb.net

New to the whole web programming scene, usually stick to offline applications.
On this page of my site I'm using gridview to pull items from an SQL database.
That's all fine and dandy, but here's where I get confused.
Upon selection of an item I want to navigate to another page which is generated with information from my SQL database, I'm fine here, I have a template for the page that pulls information for the page based on the selected item using a get property for a WHERE itemname= sql command.
However, currently, the site goes like this. http://exampleurl.com/items.aspx
I would like users to be able to link to a specific item. So upon selection it should generate a url for that item.
http://exampleurl.com/items.aspx?=selecteditemname
Never mind.
I'm just being a tard as usual.
Set the column in your gridview to a hyperlink
navigateurl='<%# String.Format("../Default.aspx?id={0}", Eval("ColumnId"))%>'
Open up the code for the page you are redirecting to and set your WHERE in the gridview to
Request.RawUrl.Split("=")(1)
This will get everything after the '=' in your url.
i.e.
http://exampleurl.com/Default.aspx?id=123
Request.RawUrl.Split("=")(1) will return '123'
OR
Dim item As String = Request.Url.Query
Dim query As NameValueCollection = HttpUtility.ParseQueryString(item)
Dim id As String = query["id"]

How to check all the links dynamically?

The following thing I have to do using VBScript in QTP 10/11:
The VBScript opens one login page. After the login it counts the number of links in that page and then prints all the links. Afterwards it opens every link one by one.
I am having issues with finding all the dynamic links.
You can get all the links on a page by using the Page's (or Frame's) ChildObject method.
Set desc = Description.Create()
desc("html tag").Value = "a"
Set links = Browser("B").Page("P").ChildObjects(desc)
For i = 0 to links.Count - 1
Print links(i).GetRoProperty("inner_text") & " => " & links(i).GetRoProperty("href")
Next
As for clicking them, that's a bit more complicated since after clicking a link you cause a navigation that invalidates the links object, you should either perform the ChildObjects each time (while keeping track of the index) or open the links in a different browser/tab.