【问题标题】:does not contain a definition for and no extension method accepting a first argument不包含定义,也不包含接受第一个参数的扩展方法
【发布时间】:2016-04-13 20:22:20
【问题描述】:

我在以下代码行收到此错误

“不包含‘RadioButtonList1_SelectedIndexChanged1’的定义,并且找不到接受‘ASP.addreservation_aspx’类型的第一个参数的扩展方法‘RadioButtonList1_SelectedIndexChanged1’(您是否缺少 using 指令或程序集引用?)”

 <asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" 
    OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged1" 
    RepeatDirection="Horizontal">

我不知道为什么会发生这种情况,因为我已经在后面的代码中有 selectedindexchanged 方法

 protected void RadioButtonList1_SelectedIndexChanged1(object sender, EventArgs e)

    }

那么有人知道这是什么问题吗?我尝试清理项目并重建,但它不起作用。

【问题讨论】:

  • 你有没有想过这个问题?

标签: c# asp.net radiobuttonlist selectedindexchanged


【解决方案1】:

私人图像填充图像; 私有文本 textLabel;

private float value = 0f;
private bool isDone = false;

void Awake() 
{
    this.fillImage = this.transform.Find("Fill").GetComponent<Image>();
    this.textLabel = this.transform.Find("Text").GetComponent<Text>();
    
    
}
// Start is called before the first frame update
void Start()
{
    this.fillImage.fillAmount = 0f;
    
}

// Update is called once per frame
void Update()
{
    if (this.isDone)
    {
        if(this.OnDoneEvent != null)
            this.OnDoneEvent ();

        this.OnDoneEvent = null;
        this.OnchangeEvent = null;
        return;
    }

    if(this.OnchangeEvent != null)
       this.OnchangeEvent((int)(this.value *100));

    this.fillImage.fillAmount = this.value;
    this.textLabel.text = (this.value >= 1) ? "Done!" : (this.value * 100) + "%";
    this.isDone = (this.value >= 1)? true : false;
    
}
#region Get and set
public void setValue(float value )
{
    this.value = value;
}
public float GetValue()
{
    return this.value;
}

#endregion

#region Events
public void onChange(valueChanged method)
{
    this.OnChangeEvent += method;
}

public void onDone(ProgressDone method)
{
    this.OnDoneEvent += method;
}

public delegate void valueChanged(float value);
private event valueChanged OnchangeEvent;

public delegate void ProgressDone();
private event ProgressDone OnDoneEvent;

#endregion

【讨论】:

  • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
【解决方案2】:

可能是您缺少事件的左括号,这就是原因

 protected void RadioButtonList1_SelectedIndexChanged1(object sender, EventArgs e)
{
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-05-21
    • 2014-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-06
    • 2023-03-13
    • 2019-07-29
    相关资源
    最近更新 更多