Link to home
Start Free TrialLog in
Avatar of jagguy
jagguyFlag for Australia

asked on

inner html and asp.net

i want to just click on a button and more html code is added to my webpage from code behind .

this works but when i click on button i want the  one.InnerHtml  to repeat so i get another hello on every button click

  <div id="one" Runat="server" ></div>


    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim a As String
       
        one.InnerHtml = "<h2>hello</h2><br>asas"


    End Sub

how do i keep displaying  another message from above?
Avatar of Anurag Agarwal
Anurag Agarwal
Flag of India image

try

one.InnerHtml += "<h2>hello</h2><br>asas"

Anurag
Avatar of jagguy

ASKER

ok but how do i get different text to display in label or any any control i use to display text?
the text will go where label3 is

    one.InnerHtml += "<br/> <br/> <div class='sidebox1'><div class='boxhead1'><h2>Teacher Version</h2></div>" & _
                            "<div class='boxbody1'><asp:Label ID='Label13' runat='server' Text='Label'>" & _
                            "</asp:Label><br/> <br/>  </div>     </div>"
ASKER CERTIFIED SOLUTION
Avatar of AmarIs26
AmarIs26

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jagguy

ASKER

it works fine

    Private Sub LoadGrid()
        Dim count, i As Integer
        Dim a As String
        a = "hello wprld"
        ' one.InnerHtml = "<h2>hello</h2><br>asas"
    
 
        Dim da As New SqlDataAdapter
 
        Dim command As SqlCommand
        command = New SqlCommand
 
        command.CommandText = "  SELECT  name,date,comment from blog order by date desc"
 
        command.Connection = Myconn
        da.SelectCommand = command
 
        da.Fill(ds, "blog")
        count = ds.Tables(0).Rows.Count
        For i = 0 To count - 1
            one.InnerHtml += "<br/> <br/> <div class='sidebox1'><div class='boxhead1'><h2>Teacher Version</h2></div>" & _
                                    "<div class='boxbody1'><br/>" & ds.Tables(0).Rows(i).Item(2) & "<br/> <br/>  </div>     </div>"
 
        Next
 
 
    End Sub

Open in new window

Avatar of AmarIs26
AmarIs26

Ok, i am not a vb programmer so didnt know += works in vb. anyways for your string concatanation you should use the StringBuilder class as it offers better performance.
http://www.c-sharpcorner.com/UploadFile/mahesh/WorkingWithStringsP311232005021723AM/WorkingWithStringsP3.aspx