Solved

inner html  and asp.net

Posted on 2008-10-29
5
2,743 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

743 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

13 Experts available now in Live!

Get 1:1 Help Now