从数据库读取数据并将数据设置为html输入类型的值 [英] Reading data from database and setting data to value in input type in html

查看:131
本文介绍了从数据库读取数据并将数据设置为html输入类型的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有个问题要解决。我从数据库设置数据中读取数据到javascript中的文本值。但是值数据无法正确显示在页面中。例如,如果值仅等于value = hello friends看到你好。我怎么解决这个问题。

Hi I have problem to be solved.I read data from database setting data to text value in javascript .But the value data does not seen in page correctly.For example if the value is equal to value="hello friends " only "hello" is seen . How can I solve this problem.

这里是代码:-

    <input type=" + "text" + " value="+login+" id=" + Type + " name=" + Type + " size=" + "40" + " maxlength=" + "200" + " />

show data:-

    <input type=text value=Lütfen kullanıcı adınızı girin id=Kullanıcı  Girisi name=Kullanıcı  Girisi size=40 maxlength=200 />

only Lütfen is seen..

BlockCode:-

    StringBuilder sb = new StringBuilder();
               List<LoginVO> loginVO = new List<LoginVO>();
               loginVO = formBUS.Login(GrpID);
               login = loginVO[0].Value;
               sb.AppendLine("<table cellpadding=\"0\" cellspacing=\"0\" class=\"custom-tablePopup\">");
               sb.AppendLine("<tr><th>" + Type + ":</th> <th><input type=" + "text" + " value="+login+" id=" + Type + " name=" + Type + " size=" + "40" + " maxlength=" + "200" + " /><th></tr>");

               //SaveData(icerik);
               sb.AppendLine("<tr cellpadding=\"0\" cellspacing=\"0\">");
               //sb.AppendLine("<tr><td>" + dr["DrpBanner2"].ToString() + "</td></tr>");
               // icerik = dr["DrpBanner2"].ToString();
               sb.AppendLine("</tr>");
               //icerik = dr["DrpBanner2"].ToString();
               //SaveData(icerik);
               sb.AppendLine("</table>");
               LitformSon.Text += sb.ToString();


推荐答案

引号存在问题。试试这个;

There is a issue with quotes. Try this;

<input type=" + "\"text\"" + " value=\""+login+"\" id=\"" + Type + "\" name=\"" + Type + "\" size=" + "\"40\"" + " maxlength=" + "\"200\"" + " />

谢谢!

这篇关于从数据库读取数据并将数据设置为html输入类型的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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