?
Solved

VB.NET WEB FORMS Inner text

Posted on 2011-05-08
16
Medium Priority
?
311 Views
Last Modified: 2012-05-11
hi all.
i have a problem.
On webForm I must insert text to this textarea.
1st:
<input class="pledge_level_other" name="PledgeLevelOther" value="" onchange="liltype.ifaw.setDonationOther(this.form);" type="text" maxlength="12" size="12">

Open in new window

2nd:
<input type="text" size="35" maxlength="250" name="first_name" value="">

Open in new window

And 3hd i need to click the button
<input type="button" name="SubmitButton" id="SubmitButton" value="Submit" onclick="SubmitForm285190(form);" class="HtmlButton">

Open in new window

I use Webbrowser.
0
Comment
Question by:Replica178
  • 7
  • 6
  • 3
16 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35715803
Try the following:
Dim inputs As HtmlElementCollection = Me.WebBrowser1.Document.GetElementsByTagName("input")

For Each element As HtmlElement In inputs
    If element.Name = "PledgeLevelOther" Then
        element.InnerText = "some text to enter"
    ElseIf element.Name = "first_name" Then
        element.InnerText = "my name"
    End If
Next

Dim button As HtmlElement = Me.WebBrowser1.Document.GetElementById("SubmitButton")

If button IsNot Nothing Then
    button.InvokeMember("click")
End If

Open in new window

0
 

Author Comment

by:Replica178
ID: 35715909
Not Working(
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35715915
Where did you put that code? It needs to go into Webbrowser1_DocumentCompleted event and add a check to make sure that document has fully loaded.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35715920

    Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        If WebBrowser1.ReadyState = System.Windows.Forms.WebBrowserReadyState.Complete Then
           'Above Code
        End if
End Sub
0
 

Author Comment

by:Replica178
ID: 35715928
I put it into the button
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim inputs As HtmlElementCollection = Me.WebBrowser1.Document.GetElementsByTagName("input")

        For Each element As HtmlElement In inputs
            If element.Name = "PledgeLevelOther" Then
                element.InnerText = "some text to enter"
            ElseIf element.Name = "first_name" Then
                element.InnerText = "my name"
            End If
        Next

        Dim button As HtmlElement = Me.WebBrowser1.Document.GetElementById("SubmitButton")

        If button IsNot Nothing Then
            button.InvokeMember("click")
        End If
    End Sub

Open in new window

0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35715941
And you are sure that the page is fully loaded? Did you step through the code?
0
 

Author Comment

by:Replica178
ID: 35715953
yes.i'm sure
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35715960
>Did you step through the code?
And which lines are executing?
0
 

Author Comment

by:Replica178
ID: 35715980
it's all my code
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim inputs As HtmlElementCollection = Me.WebBrowser1.Document.GetElementsByTagName("input")

        For Each element As HtmlElement In inputs
            If element.Name = "PledgeLevelOther" Then
                element.InnerText = "some text to enter"
            ElseIf element.Name = "first_name" Then
                element.InnerText = "my name"
            End If
        Next

        Dim button As HtmlElement = Me.WebBrowser1.Document.GetElementById("SubmitButton")

        If button IsNot Nothing Then
            button.InvokeMember("click")
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        WebBrowser1.Navigate("https://www.ifaw.org/ifaw_russia/donate_now/index.php#x")
    End Sub
End Class

Open in new window

0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35715988
I try again with my questions

Did you step through the code in button click?
And which lines are executing?
0
 

Author Comment

by:Replica178
ID: 35716009
i have tried  to do it step by step with 2 buttons.but it's not working.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35716020
Steping through the code means set a break point at a specific line and then executing one line of code at a time to see what code is executing and whether if conditions are returning true or false etc.

http://www.youtube.com/watch?v=jxR_ngGIpQM
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 35716234
It doesn't work because that section of the page is actually a frame, and as such, is basically it's own separate page. Try navigating to the frame's address: WebBrowser1.Navigate("https://www.kintera.org/site/c.kiKSL4PNLvF/b.4423519/k.D6A4/Donation/apps/ka/sd/donor.asp?c=kiKSL4PNLvF&b=4423519&en=ckIRL3MIKaKMLbOXJeKMI9PRKmK7IeOMKhITI2OKLeITL8OWLyF#scrollup&")
0
 

Author Comment

by:Replica178
ID: 35716264
Thank You Very Much
0
 

Author Closing Comment

by:Replica178
ID: 35716265
Thanks
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35716577
NP. Glad to help  = )
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Integration Management Part 2
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question