Click here to Skip to main content
15,909,645 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am creating a website dynamically which is retrieve data from database i tried it still but i am getting in problem a tool i use here
Literal1
in this i tried to data take from button event till now
Public Function getmenu() As String

       str += str & "<ul>"
       str = str & "<li> <a href=""> <span>"></span><span>Contact Us2</span></a></li>"
       str = str & "<ul>"


       Return str
   End Function


this is not shows till i use another tool of label with same as
Literal1.Text = getmenu()
        Label1.Text = getmenu()

now its works but bellow shows on blank Menus and a bullet point in starting
if i use image code same in this its works
'Dim src As String = Page.ResolveUrl("~/download.png")
        'Literal1.Text = String.Format("<img id='Image3' src='{0}' alt=' ' height='100' width='80' />", src)


What I have tried:

Public Function getmenu() As String

       str += str & "<ul>"
       str = str & "<li> <a href=""> <span>"></span><span>Contact Us2</span></a></li>"
       str = str & "<ul>"


       Return str
   End Function


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        
        Literal1.Text = getmenu()
        Label1.Text = getmenu()

    End Sub

in web page
<asp:Literal ID="Literal1" runat="server"></asp:Literal>	




'Dim src As String = Page.ResolveUrl("~/download.png")
        'Literal1.Text = String.Format("<img id='Image3' src='{0}' alt=' ' height='100' width='80' />", src)
Posted
Updated 28-Aug-19 1:57am
Comments
Richard Deeming 8-Aug-19 10:24am    
str += str & "<ul>"

You haven't declared the variable str.

You've also added two copies of the current value (if any) at the start. Either use str += "..." or str = str & "...".
irfanansari 9-Aug-19 16:52pm    
sir i have no issue in str or str + i have just issue in
<asp:literal id="Literal1" runat="server"> when i try to take out put of this css code function in Literal1 then it is not shows out put just shows blank and as i incluse a label with same function called then its works

1 solution

html encodes strings
HTML
<ul>, <li> and <a>

while displaying this on web page

so decode the string first

try like this
C#
Literal1.Text  = HttpContext.Current.Server.HtmlDecode(stringContents);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900