如何在加载时从ajax colorpickerextender中使用的文本框中隐藏颜色代码[讨论]

时间:2022-01-18 03:17:51


I am using ajax colorpickerextender control for color selection. For TargetControlID, I have used a textbox. It shows hexadecimal color code into that textbox. Using this post I have resolved this for colorselection change event.
I am saving selected color into an xml file and reassigning it to the color control when form loads.
My problem is at loading it shows hexadecimal code.
Does anyone know how to resolve this issue?
Thanks in advance.

我正在使用ajax colorpickerextender控件进行颜色选择。对于TargetControlID,我使用了一个文本框。它在该文本框中显示十六进制颜色代码。使用这篇文章,我已经解决了这个问题,因为colorselection change事件。我将选定的颜色保存到xml文件中,并在表单加载时将其重新分配给颜色控件。我的问题是加载它显示十六进制代码。有谁知道如何解决这个问题?提前致谢。

2 个解决方案

#1


0  

I tried setting the back color and fore color to transparent, but it didn't worked for all the browsers. Now, what I did is, I set these properties, the selected color. So unless and until user explicitly moves cursor inside the color text box and selects the text inside it, this is not catchable. So for the time being issue is resolved at first sight.

我尝试将背面颜色和前面颜色设置为透明,但它并不适用于所有浏览器。现在,我所做的是,我设置这些属性,选择颜色。因此,除非用户明确地将光标移动到颜色文本框内并选择其中的文本,否则这是不可捕获的。所以暂时问题一见钟情就解决了。

#2


0  

Not a very elegant solution, but try to set backcolor and forecolor to Transparent: Not a very elegant solution, but try this. It's stteing backcolor and forecolor to Transparent:

不是一个非常优雅的解决方案,但尝试将backcolor和forecolor设置为Transparent:不是一个非常优雅的解决方案,但试试这个。它将backcolor和forecolor设置为Transparent:

<asp:TextBox ID="txtColor" runat="server" Text='<%# Bind("Color") %>' BackColor='<%# System.Drawing.Color.Transparent %>'
                                width="0px" Enabled="false" ForeColor='<%# System.Drawing.Color.Transparent %>' BorderStyle="None" BorderColor='<%# System.Drawing.Color.Transparent %>'></asp:TextBox>
                            <asp:TextBox ID="txtColorSample" runat="server"  
                                Width="20px" BorderStyle="None" BackColor='<%# System.Drawing.ColorTranslator.FromHtml(IIF(IsDbNull(Eval("Color")),"#FFFFFF",Eval("color")))%>'></asp:TextBox>

#1


0  

I tried setting the back color and fore color to transparent, but it didn't worked for all the browsers. Now, what I did is, I set these properties, the selected color. So unless and until user explicitly moves cursor inside the color text box and selects the text inside it, this is not catchable. So for the time being issue is resolved at first sight.

我尝试将背面颜色和前面颜色设置为透明,但它并不适用于所有浏览器。现在,我所做的是,我设置这些属性,选择颜色。因此,除非用户明确地将光标移动到颜色文本框内并选择其中的文本,否则这是不可捕获的。所以暂时问题一见钟情就解决了。

#2


0  

Not a very elegant solution, but try to set backcolor and forecolor to Transparent: Not a very elegant solution, but try this. It's stteing backcolor and forecolor to Transparent:

不是一个非常优雅的解决方案,但尝试将backcolor和forecolor设置为Transparent:不是一个非常优雅的解决方案,但试试这个。它将backcolor和forecolor设置为Transparent:

<asp:TextBox ID="txtColor" runat="server" Text='<%# Bind("Color") %>' BackColor='<%# System.Drawing.Color.Transparent %>'
                                width="0px" Enabled="false" ForeColor='<%# System.Drawing.Color.Transparent %>' BorderStyle="None" BorderColor='<%# System.Drawing.Color.Transparent %>'></asp:TextBox>
                            <asp:TextBox ID="txtColorSample" runat="server"  
                                Width="20px" BorderStyle="None" BackColor='<%# System.Drawing.ColorTranslator.FromHtml(IIF(IsDbNull(Eval("Color")),"#FFFFFF",Eval("color")))%>'></asp:TextBox>