Click here to Skip to main content
14,697,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to find a specific div tag of a website's page in my own webpage using asp.net. how to do it. please help me.
Posted

Hi,

You need to add an id attribute and runat="server" into your div:
<div id="div1" runat="server">Your content</div>

Now, in your code-behind file, you can use div1 as a variable:
C# code:
string htmlInDiv1 = div1.InnerHtml;

VB.NET code:
Dim htmlInDiv1 As String = div1.InnerHtml

If the div is in an external page, then you need to read the XML of the page:
http://www.c-sharpcorner.com/UploadFile/mahesh/ReadWriteXMLTutMellli2111282005041517AM/ReadWriteXMLTutMellli21.aspx[^]
XML File Parsing in VB.NET[^]

Hope this helps.
   
v2
Comments
saifullahiit 26-Dec-12 5:18am
   
suppose in your code the div with id "div1" is a tag in a webpage say www.codproject.com i want to access that "div1" tag in my own web page. so how i will reference to codeproject.com page?
Thomas Daniels 26-Dec-12 6:17am
   
I updated my answer.
Give id to div tag and add runat="server" attribute, then u will be able to access the div in c#.

To add content to Div use divID.InnerText or divID.InnerHTML = "content"

Hope this helps!
   

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