locked
how to Create HTML <li> tag randomly from database in asp.net RRS feed

  • Question

  • User-1452537652 posted

    hi guys, i am facing a big problem.


    I want to create HTML <li> tag randomly, mean

    i want to create random <li> tag from database, like

    <ul>

    <li>

    home</li>

    now i want some of the li tag like (location) jaipur, Chandigarh, Delhi etc will genrate according the value of my databse


    Please Reply fast.

    Saturday, April 17, 2010 2:11 AM

Answers

  • User1571885900 posted

    Hi,

    creat a repeater for ex:

     

     <asp:Repeater ID="Repeater1" runat="server">
                    <HeaderTemplate>
                        <ul>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <li>
                            <%# Eval("CityName") %>
                        </li>
                    </ItemTemplate>
                    <FooterTemplate>
                        </ul>
                    </FooterTemplate>
                </asp:Repeater>


     

    Get data from database and assing it to repeater, this will generate <Li> tags dynamically.

     

     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, April 17, 2010 8:45 AM

All replies

  • User1571885900 posted

    Hi,

    creat a repeater for ex:

     

     <asp:Repeater ID="Repeater1" runat="server">
                    <HeaderTemplate>
                        <ul>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <li>
                            <%# Eval("CityName") %>
                        </li>
                    </ItemTemplate>
                    <FooterTemplate>
                        </ul>
                    </FooterTemplate>
                </asp:Repeater>


     

    Get data from database and assing it to repeater, this will generate <Li> tags dynamically.

     

     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, April 17, 2010 8:45 AM
  • User-1452537652 posted

    Thanks a lot paresh


    you solved my problem dude...


    can u please tell me one more thing


    do u know how to create HTML tags via C# code or VB code

    Tuesday, April 20, 2010 2:40 AM
  • User-330204900 posted

    You can just use Text or you could use an HtmlTextWriter

    HtmlTextWriter writer = new HtmlTextWriter();
    
    // render button
    writer.AddAttribute(HtmlTextWriterAttribute.Id, linkButtonId);
    writer.AddAttribute(HtmlTextWriterAttribute.Name, linkButtonId);
    writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClass);
    writer.AddAttribute(HtmlTextWriterAttribute.Type, "button");
    writer.AddAttribute(HtmlTextWriterAttribute.Value, Text);
    writer.RenderBeginTag(HtmlTextWriterTag.Input);
    writer.RenderEndTag();
    
    Page.Response.Write(writer);

    This will render an input button.

    Tuesday, April 20, 2010 4:57 AM
  • User1571885900 posted

    Hi,

    Otherway to write HTML tag from codebehind is, take a Literal control and assing HTML string to it.

    for examplel:
    <asp:Literal ID="Literal1" runat="server"></asp:Literal>


    Literal1.Text = "<div style=\"color:red;\">Hi, How are you</div>";

     

    But in this way there are chances that you will get error like:
    A potentially dangerous Request.Form value was detecte......


    you can ser validateRequest="false" to overcome this error

    but you should refer http://msdn.microsoft.com/en-us/library/ms998274.aspx for more detail

    Wednesday, April 21, 2010 4:29 AM
  • User-1452537652 posted

    thanks guys...

    thanks to all.......


    can any one please tell me how to bind ajax asp.net rating control with the database..


    like i have an question

    and it has three option like yes, no cantsay....

    now i want to show the streanth of the option according databse like orkut


    thanx

    Friday, April 23, 2010 5:22 AM
  • User624952157 posted

    Hey i want to generate one dynamic ui and li html menu  and the text for ui and li can i get from database.

    so dynamically create the ui and li........please tell me

    if u have good example..........

    Tuesday, June 14, 2011 3:27 AM
  • User-1452537652 posted

    hi saroop, you can easly create the ul li menu dynamicaly...

    follow these steps

    1. Find a good HTML example as you want...

    2. than add css and js in head tag as, html showing....

    3. than take a repeater and put li or any tag you want to repeat in repeater item template..

    4. bind repeater with database..

    you will got your solution..

    Thanks and Regards

    Inderjeet Singh

    Wednesday, August 3, 2011 8:43 AM