如何从数据库中检索值并以正确的HTML格式显示它 [英] How to retrieve the values from a database and display it in proper HTML format

查看:98
本文介绍了如何从数据库中检索值并以正确的HTML格式显示它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用一些HTML标记将值存储到数据库中.当我检索该值时,它应该在文本框中显示它,例如,如果我要保存 Manchestor 之类的值,它应该在文本框中以粗体显示,并且如果我另存为manchestor
Sanfrancisco,它应该显示为

机械手
旧金山

在此先感谢

Hi,

I am storing the values into the database with some HTML tags. When I retrieving that values it should display it in a textbox like if I am saving the value like Manchestor it Should display in bold in the textbox and if I save as manchestor
Sanfrancisco it should display like

manchestor
Sanfrancisco

Thanks in Advance

推荐答案

在这里将HTML 文本存储在数据库中可能不是问题.主要问题是要具有合适的控件,该控件可以根据需要呈现文本.

为此,我认为此CodeProject文章中给出的控件
您将使用的专业HTML渲染器 [ ^ ]
可能会有所帮助.
Here storing the HTML text in the database may not be an issue. The main issue is to have suitable control which can render the text as desired.

For this purpose I think the control given in the this CodeProject article
A Professional HTML Renderer You Will Use[^]
may be helpful.


SqlParameter Screenname = new SqlParameter("@ScreenName", GlobalList[count]);
                Screenname.SqlDbType = SqlDbType.VarChar;
                SqlCommand cmd_sel = new SqlCommand("Select * from userInfo where ScreenName=@ScreenName ", con);
                cmd_sel.Parameters.Add(Screenname);
                con.Open();
                SqlDataReader dr = cmd_sel.ExecuteReader();
                if (dr.Read())
                {
                                        str.AppendFormat("<ul> <div>  <div> <div>  ");
                    str.AppendFormat("<li> <input type=\"button\" id=\"btnTextChat\" value=\"TextChat\" /> </li>");
                    str.AppendFormat("<li><input type=\"button\" id=\"btnSendMessage\" value=\"Send Message\" />  </li> ");
                    str.AppendFormat("<li><input type=\"button\" id=\"btnAudioVideoChat\"  value=\"Audio-Video Chat\" /> </li>");
                    str.AppendFormat("<li><input type=\"button\" id=\"btnWink\" value=\"Wink\" /> </li>");
                    str.AppendFormat("</ul> </div>  </div> </div>  ");
                    count++;
                }
                con.Close();


这篇关于如何从数据库中检索值并以正确的HTML格式显示它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆