javascript - Toggle HtmlEncode on asp:BoundField -
title pretty self explanatory. have 2 bound fields , want toggle them function (either js or c#). i'm not sure how since not have id elements.
here code:
<asp:boundfield datafield="fieldoldvalue" headertext="fieldoldvalue" htmlencode="false"/> <asp:boundfield datafield="fieldnewvalue" headertext="fieldnewvalue" htmlencode="false"/> <label class="switch"> <input id="htmltoggle" type="checkbox" onclick="togglehtml()"> <span class="slider round"></span> </label>
ideally js this:
function togglehtml() { if('htmltoggle'.checked) //render html (htmlencode="false") else //un-render html (htmlencode="true") }
the fields showing raw html initially, , when hit toggle, both fields render html.
update: have maybe gotten closer solving still not getting work (i'm trying either asp:button or toggle). here more code:
currently trying button:
<asp:button runat="server" text="swap" id="htmltoggle2" class="btn" onclick="swaphtml"/>
c#:
protected void swaphtml(object sender, eventargs e) { if (((boundfield)gridview2.columns[2]).htmlencode.equals(false)) { ((boundfield)gridview2.columns[2]).htmlencode = true; ((boundfield)gridview2.columns[3]).htmlencode = true; } else { ((boundfield)gridview2.columns[2]).htmlencode = false; ((boundfield)gridview2.columns[3]).htmlencode = false; } }
Comments
Post a Comment