?
Solved

inner html  and asp.net

Posted on 2008-10-29
5
Medium Priority
?
2,822 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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

752 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