Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7849363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:29:44+00:00 2026-06-02T18:29:44+00:00

Here is a piece of my code through which i am rendering html controls

  • 0

Here is a piece of my code through which i am rendering html controls with runat=”server”

 var sb= new StringBuilder();
 sb.AppendLine(" <div class='ItemDiv'>");
 sb.AppendLine(" <h2>More Products </h2>");
 sb.AppendLine("  <span class='separator'></span> <ul class='ulProducts'>");
 foreach (var lead in list)
 {
    var name = lead.ProductName;
    if (name.Length > 17)
    {
       name = string.Format("{0}...", name.Substring(0, 17));
    }
    sb.AppendLine(string.Format("<li><img src='{0}' align='absmiddle' alt='{1}'/> 
                                    <span class='separator'> </span>
                                     <a href='~/Item/{2}/{1}.aspx' runat='server' // issue is with runat='server' 
                                      style='font-size:8pt; text-transform:                      
                                      capitalize;'>{1}</a></li>", 
                                lead.ProductImagePath, name,lead.Id));
 }
 sb.AppendLine("</ul> </div>");
 ProductsBySame1.GetHtml = sb.ToString(); // ProductsbySame is usercontrol and GetHtml is property of innerHtml of div placed in the usercontrol. That is dynamically populated.

My output:

<div id="ctl00_cphMain_ProductsBySame1_ltlProducts"> <div class='ItemDiv'>

 <h2>More Products </h2>

 <span class='separator'></span> <ul class='ulProducts'>

<li><img src='Uploads/Images/8e4c426aa1464af0b45f43c8c773e8ae.jpg' align='absmiddle' alt='Ceftriaxone Injec...'/> <span class='separator'> </span><a href='~/Item/659/Ceftriaxone Injec....aspx' **runat='server'**  style='font-size:8pt; text-transform: capitalize;'>Ceftriaxone Injec...</a> </li>

<li><img src='Uploads/Images/9efa7b61cf9f467393089ca111fc5f51.jpg' align='absmiddle' alt='Clavulanate Potas...'/> <span class='separator'> </span><a href='~/Item/660/Clavulanate Potas....aspx' **runat='server'**  style='font-size:8pt; text-transform: capitalize;'>Clavulanate Potas...</a> </li>

</ul> </div>

</div>

See ** above. Actually i am using UrlRewriting.Net module to rewrite urls. And as per their documentation the links starting with ~/ will work only. So I ambuilding my url as and since ~/ works only with runat=’server’.

So finally my issue is that my above href is not working as the runat=’server’ is not resolved while rendering. Please help me while rendering the html , as per my scenario of usage.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:29:47+00:00Added an answer on June 2, 2026 at 6:29 pm

    Just use a Repeater control instead of building html from scratch:

    <asp:Repeater ID="MyRepeater" runat="server">
        <HeaderTemplate>
            <div class="ItemDiv">
                <h2>More Products </h2>
                <span class='separator'></span>
                <ul class='ulProducts'>
        </HeaderTemplate>
    
        <ItemTemplate>
            <li>
                <img src="<%...%>" align="absmiddle" alt="<%...%>" /> 
                <span class='separator'> </span>
                <a href="<%...%>" runat="server" style="font-size:8pt; text-transform:capitalize;"><%...%></a>
            </li>
        </ItemTemplate>
    
        <FooterTemplate>
                </ul>
            </div>
        </FooterTemplate>
    </asp:Repeater>
    

    (added dummy placeholders for binding)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the piece of code, which run through all the process and when
Here is the piece of code which I use to get the count from
I have a small piece of code here for your consideration which puzzles me
Here's a piece of code I wrote for cleaning A string of unwanted chars
Here's a piece of code to take a string (either NSString or NSAttributedString) input
Here is the piece of code that I have used for Java 5.0 TreeSet<Integer>
Here's a piece of code from the xss_clean method of the Input_Core class of
Here's a piece of code that takes most time in my program, according to
Here's a piece of code, currently driving me nuts. It's a UIView, with an
Here is an interesting piece of code that my fellow team members were just

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.