vb.net - Decoding HTML and databinding into a ASP.NET repeater -


i have separate page use server.htmlencode feature encode html user has entered inside of htmleditorextender on textbox.

i trying insert html repeater so:

<asp:repeater id="articlelist" runat="server">     <itemtemplate>         <div class="itemtemplate">          <h2><%#container.dataitem("title")%></h2>          <h5>category:</h5> <%#container.dataitem("category")%><br />         <%#container.dataitem("decodedhtml")%>         <%#container.dataitem("username")%>         <%#container.dataitem("dateofpost")%>     </div>     </itemtemplate>     <alternatingitemtemplate>     <div class="altitemtemplate">      <h2><%#container.dataitem("title")%></h2>          <h5>category:</h5> <%#container.dataitem("category")%><br />         <%#container.dataitem("decodedhtml")%>         <%#container.dataitem("username")%>         <%#container.dataitem("dateofpost")%>     </div>     </alternatingitemtemplate>     </asp:repeater> 

and code behind:

sub displayarticles()     dim conn new oledb.oledbconnection(configurationmanager.connectionstrings("bookmeetconnstring").connectionstring)     conn.open()     dim cmd new oledbcommand("select * [userarticles] order dateofpost desc", conn)     dim inputstring string = "htmlbody"     dim decodedhtml string = server.htmldecode(inputstring)     articlelist.datasource = cmd.executereader()     articlelist.databind()     conn.close() end sub 

"htmlbody" name of field in database encoded html in.

unfortunately, receiving error

"indexoutofrangeexception unhandled user code". 

there problem here referring string decodedhtml in container.dataitem statement, doing wrong?

edit: code other page html encoded:

    protected sub button1_click(sender object, e eventargs) handles button1.click          if string.isnullorempty(textbox1.text)         errormessage.visible = true         errormessage.text = "your submission blank. please write article first"         else             dim oledbconn new oledb.oledbconnection(configurationmanager.connectionstrings("bookmeetconnstring").connectionstring)             dim sqlstring string = "insert userarticles(title,category,username,dateofpost,htmlpost) values (@f1,@f2,@f3,@f4,@f5)"             dim htmlencode string = server.htmlencode(textbox1.text)             dim cmd oledbcommand = new oledbcommand(sqlstring, oledbconn)             cmd.commandtype = commandtype.text             cmd.parameters.addwithvalue("@f1", articletitle.text)             cmd.parameters.addwithvalue("@f2", categorydropdown.selectedvalue)             cmd.parameters.addwithvalue("@f3", user.identity.name)             cmd.parameters.addwithvalue("@f4", datetime.now.date)             cmd.parameters.addwithvalue("@f5", htmlencode)             oledbconn.open()             cmd.executenonquery()             textbox1.text = nothing             articletitle.text = nothing             categorydropdown.clearselection()         end if end sub 

from looks of it, decodedhtml string creating in code. not accessible through .aspx page.

you should able update .aspx markup to;

<%#server.htmldecode(container.dataitem("[column_name"))%> 

where [column_name] actual table column holds encoded html value.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -