[英]In ASP.net I want to setting some value into a textbox and then get the value in server side
It is my Code. 这是我的代码。 And i have to use the plug in.
而且我必须使用插件。
This is the plug-in website: http://jscolor.com/download/ 这是插件网站: http : //jscolor.com/download/
It just a color picker plug-in. 它只是一个拾色器插件。
MyCode:
<div class="FormItem">
<asp:Label ID="lblColor" runat="server">Color : </asp:Label>
<asp:TextBox ID="rColor" runat="server" ReadOnly="true"></asp:TextBox>
<input ID="txtColor" class="jscolor {onFineChange:'update(this)'}"readonly="readonly" ></input>
This is the Function which update the color and text of the textBox. 这是用于更新文本框的颜色和文本的功能。
function update(jscolor) {
document.getElementById('<%=rColor.ClientID%>').style.backgroundColor = '#' + jscolor;
document.getElementById('<%=rColor.ClientID%>').value = '#' + jscolor;
}
How can i get the value of the TextBox in the server site. 我如何获取服务器站点中TextBox的值。
I have tried to get rColor.Text in server site. 我试图在服务器站点中获取rColor.Text。 It show me nothing inside of the TextBox(rColor).
它没有显示TextBox(rColor)内的任何内容。
This is my Server site Get value of TextBox code: 这是我的服务器站点,获取TextBox代码的值:
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('" + rColor.Text + "');", true);
project.Color = rColor.Text;
This still show the color which is Page_Load function load the value from database. 这仍然显示颜色,这是Page_Load函数从数据库中加载值。
Problem is because of setting the textbox as readonly. 问题是由于将文本框设置为只读。
Refer this issue textbox value change not being reflected in code behind c# 请参阅此问题文本框值更改未反映在C#背后的代码中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.