Solved

inner html  and asp.net

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

Suggested Solutions

Title # Comments Views Activity
disable data migrations in visual studio 2017 4 50
Timer on div 5 24
output in HTML in Powershell 5 28
html5 1 17
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
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 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…

726 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