Welcome Guest Search | Active Topics | Sign In | Register

Loading data in a textbox on a web page on VB.NET Options
Prequena84
Posted: Monday, June 21, 2021 4:15:38 PM
Rank: Advanced Member
Groups: Member

Joined: 5/10/2021
Posts: 43
Hello good afternoon, I need help, I am having a problem with a code, I need to load data in a Textbox in the Browser, I need a Function that allows me to enter the data in this HTML:

<input id="input-email" type="text" name="email" inputmode="text" class="Input-bsp0cd-0 boaZvM" value="">



and I was testing with an idea about this:

Code: Visual Basic.NET
Public Sub Carga_Name()

        Dim Name_Web As String = Form1.Nombre
        Dim CantidadLetras1 As Integer = Len(Name_Web)
        Dim Letra As String

        CantidadLetras1 = Len(Name_Web)

        For i = 1 To CantidadLetras1

            Letra = Mid(Name_Web, i, 1)
            Form1.WebView1.SendChar(Letra)
            Espera(1000)
        Next


    End Sub




The idea is that I can configure a value of the name of my client and that field can be completed automatically and that value is updated within that field on the web page, I have the webview in picture in my windows form.

I need urgent advice since I am about to deliver a project and I have 2 hours at most to do it, I thank you

Prequena84
Posted: Tuesday, June 22, 2021 3:08:36 PM
Rank: Advanced Member
Groups: Member

Joined: 5/10/2021
Posts: 43
Hello good morning Sirs of Support, I have an advance, so far I managed to load the values in the fields of the WEB through this code:

HTML tags:


Email field:
<input id="input-email" type="text" name="email" inputmode="text" class="Input-bsp0cd-0 boaZvM" value="">

Name field:
<input id="input-name" type="text" name="name" inputmode="text" class="Input-bsp0cd-0 boaZvM" value="">

Telephone field:
<input id="input-phone" type="tel" name="phone" inputmode="text" class="Input-bsp0cd-0 boaZvM" value="">



Code: Visual Basic.NET
Me.WebView1.QueueScriptCall("document.getElementById('input-email').value='" & Email & "';")


                Me.WebView1.QueueScriptCall("document.getElementById('input-name').value='" & Nombre & "';")


                Me.WebView1.QueueScriptCall("document.getElementById('input-phone').value='" & Telefono & "';")



with this code I was able to load the values in each field, however to click with:


Me.WebView1.EvalScript("document.getElementById('getPublisherData').click();")



it doesn't load the values and brings up the blank fields again, try doing something like this:


Url = Me.WebView1.Url

Dim Load As EO.WebBrowser.Request
Load = New EO.WebBrowser.Request(Url)

Me.WebView1.LoadRequest(Load)



And it didn't work either, I'm reviewing their material and I can't get an example to do this process, I ask them for some advice and when I made the purchase of their product they told me that I had the right to support, I also have 2 projects pending delivery and I need to fix the income click on this data and make an impact within the webview in the windows form.

Thank you





eo_support
Posted: Tuesday, June 22, 2021 3:44:09 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Hi,

Your code that uses QueueScriptCall to fill the form field is correct. You can also use EvalScript.

Typically, you do not use LoadRequest to just load an Url without any form data. For example, if you want to use LoadRequest load the form you mentioned in your post, you would need to have the values of the input fields in your Request object. The code will be something like this:

Code: Visual Basic.NET
Load = New EO.WebBrowser.Request(Url)
Load.PostData.AddValue("input-name", Nombre);
Load.PostData.AddValue("input-phone", Telefono);
Me.WebView1.LoadRequest(Load)


Note the second and first line of the above code that fills in the form values.

If you still have problems, you can use a traffic monitor such as Fiddler to monitor the traffic that's sent to the Web server and compare that traffic with what you see when you use a regular browser to submit the page interactively. You goal would be to use LoadRequest to produce the same package contents as if user access the page interactively.

Thanks!
Prequena84
Posted: Tuesday, June 22, 2021 5:46:08 PM
Rank: Advanced Member
Groups: Member

Joined: 5/10/2021
Posts: 43
hello again, i get the following error:




Whitelabel Error Page
This application has no explicit mapping for / error, so you are seeing this as a fallback.

Tue Jun 22 17:42:20 EDT 2021
There was an unexpected error (type = Method Not Allowed, status = 405).
Request method 'POST' not supported



so code the code:


Code: Visual Basic.NET
If Active_Datos = False Then



                Try

                    Me.WebView1.Url = Link_Producto

                Catch ex As Exception

                    GoTo Siguiente_Articulo

                End Try



                Url = Me.WebView1.Url

                Load = New EO.WebBrowser.Request(Url)
                Load.PostData.AddValue("input-email", Email)
                Load.PostData.AddValue("input-name", Nombre)
                Load.PostData.AddValue("input-phone", Telefono)
                Me.WebView1.LoadRequest(Load)

                Active_Datos = True

            Else



                Try

                    Me.WebView1.Url = Link_Producto

                Catch ex As Exception

                    GoTo Siguiente_Articulo

                End Try


            End If
eo_support
Posted: Tuesday, June 22, 2021 6:27:43 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Hi,

The code we give you is just an example for you to understand how to do a request. Exactly what will work depend on what your server want. You will need to understand and troubleshoot that part yourself. You can't just copy our code and think it will work with your server.

In your case, your server does not like a POST request. This has to do with this property:

https://www.essentialobjects.com/doc/eo.webbrowser.request.method.aspx

This is why we asked you to use a traffic monitor to see how the request is sent to your server through a normal Browser. Once you know how it looks like (the request Url, query strings, cookies, method, form contents, etc), then you can construct a Request object with your code that would generate the same request package to be sent to your web server. We won't do this part for you. We only show you the options. You have to understand each option and put the right settings together yourself. You have to do that part yourself.

Thanks!
Prequena84
Posted: Tuesday, June 22, 2021 6:36:06 PM
Rank: Advanced Member
Groups: Member

Joined: 5/10/2021
Posts: 43
Starting from this idea, what web content should I study to understand this topic more thoroughly and thus be able to apply the coding correctly?

I thank you for all the support
eo_support
Posted: Tuesday, June 22, 2021 7:00:41 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
You should use a Web traffic monitor (Fiddler is a good one) to find out the content of the request that is sent to your server and then try to duplicate it with your code. The basic steps would be like this:

1. Run the traffic monitor;
2. Start your regular Google Chrome browser, fill in the form and then click the button (such as your getPublisherData button);
3. The traffic monitor should log all the communications between your Google Chrome browser and your web server;
4. Look through the log and find the entry that you are particular interested in. For example, you might be particular interested in the log entry that contains the data sent to your web server when you click your getPublisherData button;
5. Now you will need to write code to duplicate the same contents through your code;
6. Run your code and use the same traffic monitor to compare the request data produced by your code and the request data you see in step 4. This will help you to gradually narrow the difference between the two;
7. Eventually you will be able to produce the same request content with your code as step 4. This is when your code works;

These are the basic steps --- you MUST understand the details of the package contents in order to do this correctly. Otherwise you won't be able to troubleshoot issues effectively. So if you are not familiar with those, you should search online and familiar yourself with those first. We will not be in a position to fill you in on those details as those are general web programming knowledge/concepts that is not particularly related to our product. This is the same idea as we only provide EvalScript/QueueScriptCall method. You will need to figure out the JavaScript code you passed to those methods.

Hope this points you to the right direction.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.