Solved

inner html  and asp.net

Posted on 2008-10-29
5
2,807 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 11

Expert Comment

by:Anurag Agarwal
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

729 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