Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
can some one please tell me how do i change the entire div?
here's my example,
i have created a page and it contains the following:
XML
<div id='hello'>Div Hello</div>

<div id='hello2'>Div Hello2</div>

and on my VB or C# project i want to add a Webbrowser and Button,
when i click on that button it changes this div :
XML
<div id='hello'>Div Hello</div>

to make it disappear from the page or make it's style as block or none or something(what i mean is to remove that entire div only).

i have tried this on Visual Basic 2010 Express ut it only removes text not entire Div:

        Dim HTML As String
        HTML = "<div id="hello">Div Hello</div>"
        WebBrowser1.Document.Body.InnerHtml = ""

i really appreciate if some one help me please with some code or solution

Thank You.
Posted

1 solution

Hello buddy,

you can write one javascript function that can update your div. You can call javascript function of webbrowser control page.

Please check this article to call javascript from win form :Calling JavaScript function from WinForms and vice-versa[^]

Let me know if you have any query...

Happy coding...
 
Share this answer
 
Comments
Member 10749093 14-Apr-14 20:06pm    
Thank you very much for your replay.
but i don't want that change with javascript, but change it only from my side

example, like adblocker, it blocks the ad only

so i want to make a program that already contains that divs to be removed on button

and when i click on that button, it removes that div only
AmitGajjar 14-Apr-14 20:21pm    
Yeh you can do it as well, see below link.
http://stackoverflow.com/questions/1437251/calling-a-javascript-function-in-the-c-sharp-webbrowser-control

This way you can invoke javascript.
Member 10749093 14-Apr-14 20:22pm    
ok then, i'll try it

Thank you very much.
Member 10749093 14-Apr-14 20:24pm    
oh 1 more question please,

will it work with divs that doesn't have ID or class or name?
AmitGajjar 14-Apr-14 20:40pm    
Yes you can write javascript for div. but it will apply on all divs. if you know particular location of div, it would be easier for you. like first div or 5th div etc...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900