You must Sign In to post a response.
  • Category: HTML

    Add additional tag within all span tags using c#

    I have below HTML string.

    <span class="headinglabelonimages" id="lbl133030-1" style="text-align:left;width:30px;height:10px;font-size:22px;font-weight:bold;color:#000000;"><fseparator><id_133030_1><span>Question Title</span></id_133030_1></fseparator></span>

    In c#, I want to add <p> </p> tags within all <span> tags. So that, out put looks like,

    <span class="headinglabelonimages" id="lbl133030-1" style="text-align:left;width:30px;height:10px;font-size:22px;font-weight:bold;color:#000000;"><p><fseparator><id_133030_1><span><p>Question Title</p></span></id_133030_1></fseparator></p></span>
  • #769658
    i understood as per the information provided

    you want to put <p> tag between <span> and that separator details should be in <p> tag.

    Since you have not made it runat=server you can't access it on serverside. as the span is a HtmlGenericControl
    and you should keep runat=server within the span thenonly you are able access at serverside like

    string value = span.InnerHtml;

    after reading value then replace replace <fseparator> with <p> <fseparator> and </fseparator> with </p></fseparator>

    However, in this case i'm fairly sure that you don't get the value that was changed at clientside since it is re-created from ViewState at serverside. If that's true you need to use a different approach like using a HiddenField and set it's value on clientside

    B.Ramana Reddy

  • Sign In to post your comments