简体   繁体   English

在ASP.net中,我想在文本框中设置一些值,然后在服务器端获取该值

[英]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.

相关问题 如何在ASP.NET中获取TextBox的值 - How to get value of TextBox in ASP.NET ASP.NET FindControl的文本框和获取价值 - ASP.NET FindControl Of Textbox and Get Value 设置ASP.NET Button属性客户端和读取属性值服务器端 - Setting ASP.NET Button attributes client side and read attribute value server side 将服务器端代码中的值设置为类型为“ Time”的asp.net TextBox? - Set value from server side code to an asp.net TextBox with type=“Time”? 如何使用TextMode =“Date”将服务器端代码的值设置为asp.net TextBox? - How to set value from server side code to an asp.net TextBox with TextMode=“Date”? 如何将服务器端代码中的值设置为 TextMode=“Time”的 asp.net TextBox? 时间值来自 SQL Server 数据库 - How to set value from server side code to an asp.net TextBox with TextMode=“Time”? The time value comes from SQl Server database 我想在asp.net上使用文本框上的jquery设置验证(如果选中则为最大值,则为最大值) - I want to set validation with jquery on textbox (required if checked and max value) asp.net ASP.NET MVC Razor获取文本框值 - ASP.NET MVC Razor get textbox value 如何在asp.net中获取自动完成文本框的值 - How to get the value of autocomplete textbox in asp.net 获取最后添加的文本框asp.net mvc的值 - get value of last appended textbox asp.net mvc
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM