将控件的ClientID传递给Web用户控件属性

时间:2013-11-22 07:03:43

标签: asp.net properties webusercontrol

我需要将标签控件的ClientID转换为Web用户控件。以下是在Web用户控件中创建的属性:

 public string ExternalLabelToSetTheValue
    {
        get
        {
            try
            {
                return labelToSetTheValue.Value;
            }
            catch { }
            return string.Empty;
        }
        set
        {
            try
            {
                labelToSetTheValue.Value = value;
            }
            catch { }
        }
    }

我希望将标签的ClientID传递给此属性。下面是内联代码但不起作用:

<cs:Slider ID="MaleChidCountSlider" runat="server" SliderID="MaleChidCountSlider" DisplayMode="simple" StyleUISlider="ui-sliderSimpleGraybox" StyleUIWidget="ui-widgetSimpleGraybox"
StyleUICornerAll="ui-corner-allSimpleGraybox" StyleUIState="ui-stateSimpleGraybox" ExternalLabelToSetTheValue="<%= lblChildrenCount.ClientID %>"/>

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

你试过这样的事吗:

<cs:Slider ID="MaleChidCountSlider" runat="server" 
           SliderID="MaleChidCountSlider" DisplayMode="simple" 
           StyleUISlider="ui-sliderSimpleGraybox" StyleUIWidget="ui-widgetSimpleGraybox"
           StyleUICornerAll="ui-corner-allSimpleGraybox" StyleUIState="ui-stateSimpleGraybox" 
           ExternalLabelToSetTheValue="<%# lblChildrenCount.ClientID %>"/>

或者你仍然可以在code-behind获得财产价值。