Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to change Textarea value in webbrowser control (VB2008)

Posted on 2011-02-18
10
Medium Priority
?
1,748 Views
Last Modified: 2012-05-11
I need to add text to a textarea. The application language is in Visual Basic 2008, I am using the webbrowser control.


HTML:
tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr> 
					<tr> 
						<td class="col-left">Short description:<br /><br /><i>(appears in search results)</i></td> 
						<td style="padding-bottom:5px;" class="translatable">		<div class="lang_1" style="display: block;float: left;"> 
								<textarea class="rte" cols="100" rows="10" id="description_short_1" name="description_short_1"></textarea> 
							</div>		<div class="lang_2" style="display: none;float: left;"> 
								<textarea class="rte" cols="100" rows="10" id="description_short_2" name="description_short_2"></textarea> 
							</div>		<div class="lang_3" style="display: none;float: left;"> 
								<textarea class="rte" cols="100" rows="10" id="description_short_3" name="description_short_3"></textarea> 
							</div>		</td> 
					</tr> 

Open in new window


I tried the following without success:

WB1.Document.GetElementById("description_short_1").InnerHtml = "TEST!!!!"

Open in new window

WB1.Document.GetElementById("description_short_1").OutterHtml = "TEST!!!!"

Open in new window

WB1.Document.All("description_short_1").InnerHtml = "test!!!"

Open in new window

WB1.Document.GetElementById("description_short_1").InnerHtml = "TEST!!!"

Open in new window

0
Comment
Question by:battleweb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 34931134
Use the SetAttribute method....

WebBrowser1.Document.GetElementById("description_short_1").SetAttribute("value", "TEST!!!")

Open in new window


Wayne
0
 

Author Comment

by:battleweb
ID: 34931143
I tried it and it did not work.
0
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 34931161
When are you trying to set the value? The document needs to be loaded before you can set the value.
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 

Author Comment

by:battleweb
ID: 34931201
I am using it after the document has loaded, placed code in a button for testing on demand.
0
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 34931221
Can you post more of your code? I'm not having any problems setting the value of the textbox.

The below code is from a simple form with a WebBrowser and Button control and it works fine.
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim html = <table><tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;"/></td></tr>
                       <tr>
                           <td class="col-left">Short description:<br/><br/><i>(appears in search results)</i></td>
                           <td style="padding-bottom:5px;" class="translatable"><div class="lang_1" style="display: block;float: left;">
                               <textarea class="rte" cols="100" rows="10" id="description_short_1" name="description_short_1"></textarea>
                               </div><div class="lang_2" style="display: none;float: left;">
                                   <textarea class="rte" cols="100" rows="10" id="description_short_2" name="description_short_2"></textarea>
                               </div><div class="lang_3" style="display: none;float: left;">
                                   <textarea class="rte" cols="100" rows="10" id="description_short_3" name="description_short_3"></textarea>
                               </div></td>
                       </tr>
                   </table>
        WebBrowser1.DocumentText = html.ToString
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        WebBrowser1.Document.GetElementById("description_short_1").SetAttribute("value", "TEST!!!")
    End Sub

End Class

Open in new window


Wayne
0
 

Author Comment

by:battleweb
ID: 34931282
Are there particular components that would help? There is far too much code in the page (1,029 lines) and besides it would be too difficult to parse through it and mask revealing info about my site. I did run the page in chrome and noticed that there appear to be frames and javascript at work:
<iframe id="description_short_1_ifr" src='javascript:""' frameborder="0" style="width: 100%; height: auto; "></iframe>

Open in new window


I tried some simple code:
WB1.Document.GetElementById("description_short_1_ifr").OuterHtml = "<p><strong>test</strong></p>"

Open in new window

and it shortens the textarea to 1 line and adds the "test" text but ignores the html and also generates an javascript error when i try to manually edit it afterwards:

 textarea1.jpg
0
 

Author Comment

by:battleweb
ID: 34931322
Got some more info, it is using the Tinymce Editor - I need to know how I can set text inside that editor.
0
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 34931599
That changes things greatly, but unfortunately I have no experience with the Tinymce editor, so am unable to help further.
0
 

Accepted Solution

by:
battleweb earned 0 total points
ID: 34931737
I managed to figure out a work around on my own, I'm closing this question.
0
 

Author Closing Comment

by:battleweb
ID: 34959299
I managed to figure out a work around on my own, I'm closing this question.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Read about how to choose the best possible content marketing agency to suit your needs. Content marketing has become an integral part of running a successful tech business, so it is wise to be informed.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

715 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