Solved

inner html  and asp.net

Posted on 2008-10-29
5
2,754 Views
Last Modified: 2012-05-05
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?
0
Comment
Question by:jagguy
  • 2
  • 2
5 Comments
 
LVL 11

Expert Comment

by:anuragal
ID: 22829395
try

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

Anurag
0
 

Author Comment

by:jagguy
ID: 22829456
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>"
0
 
LVL 6

Accepted Solution

by:
AmarIs26 earned 500 total points
ID: 22829581
What are trying to do is load controls dynamically. If your issue was simply to change the innerHtml of a control then string concatanation would work but because looking at your code you want the Label13 to run at server and possibally use it for user interaction then this approach would not work.
have a look at the following link
http://aspnet.4guysfromrolla.com/articles/081402-1.aspx
Also i dont think  += works in VB.net you may want to use, its fo C#. You can use one.innerHtml  = string.concat(one.InnerHtml,"other text")
 
0
 

Author Comment

by:jagguy
ID: 22829733
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

0
 
LVL 6

Expert Comment

by:AmarIs26
ID: 22829990
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
 
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

930 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now