在文本框中输入的值应b动态显示 [英] values entered in the textbox should b displayed dynamically
本文介绍了在文本框中输入的值应b动态显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在myaspx页面中有一个按钮和一个文本框...在文本框中输入的值将显示b ....再次在同一文本框中输入sm值后,它将显示下一个输入的值,而不会干扰第一个,依此类推....
i hav one button and one textbox in myaspx page...values entered in the textbox shoulb b displayed ....once again i entered sm values in the same textbox it shows the nextentered values without disturbing the first and so on....
推荐答案
将autocomplete
设置为true
将为您完成这些工作.
如果您希望从某个数据库中自动填充,请检查此 [ ^ ]
Settingautocomplete
totrue
will do the things for you.
If you wish to autofill from some database or so, check this[^]
好吧,对于初学者来说,您应该已经编辑了原始问题,而不是发布新问题..
您的页面可能应包含以下内容:
1)一个具有ID的div,为简单起见,将其称为值",并且还必须具有属性runat ="server"
2)一个ASP TextBox(您已经拥有的),将其称为NewValueBox或其他名称
3)一个ASP按钮(您已经拥有)
在按钮单击事件中,执行以下操作:
Okay for starters you should probably have edited your original question, not posted a new one, however..
Your page should probably contain the following:
1) A div that has an id, call it Values for simplicity and must also have attribute runat="server"
2) An ASP TextBox (which you already have), call this NewValueBox or something
3) An ASP Button (which you already have)
In the button click event do something like the following:
//Set the Session object with the previous values to have the new value as well
//The Session object allows you to store information between requests about a particular user.
Session["Values"] = ((string)Session["Values"]) + NewValueBox.Text + "<br />";
//Set the div inner text to have the previous values and the new value
Values.InnerHtml += ((string)Session["Values"]);
//Set the NewValueBox.Text to empty
NewValueBox.Text = "";
以下是我刚刚放在一起的Html和C#代码的工作原理:
The following is working Html and C# code I have just put together:
<body>
<form id="form1" runat="server">
<div id="ValuesDiv" runat="server">
</div><br />
<asp:TextBox ID="NewValueBox" runat="server"></asp:TextBox><br />
<asp:Button ID="Button1"
runat="server" Text="Add Value" onclick="Button1_Click" />
</form>
</body>
protected void Button1_Click(object sender, EventArgs e)
{
//Note: Use try catch block in as Session["Values"] will throw a null error for a user's first button click.
try
{
Session["Values"] = ((string)Session["Values"]) + NewValueBox.Text + "<br />";
}
catch
{
Session["Values"] = NewValueBox.Text + "<br />";
}
try
{
ValuesDiv.InnerHtml = ((string)Session["Values"]);
NewValueBox.Text = "";
}
catch
{
}
}
您可以尝试以下概念:
对自动完成文本输入进行标记化
You can try the concept:
Tokenizing Autocomplete Text Entry
这篇关于在文本框中输入的值应b动态显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文