开发者

Code Behind file event handler with c#

I have a dropdownlist that displays "Select", I want to insert an event handler in my code behind file using c#. So that when "Select" is selected in the dropdownlist it will display a warning message on the webpage.

Curretnly I have:

   protected void UpdateEmployeeBTN_Click(object sender, EventArgs e)
    {
        if (DropDownListEmployee.SelectedValue == "Select")
        {
            Response.Write("warning");
            return false;
        }
 update code...
}

I get an error/warning message for the return statement: "returns void, a return开发者_运维问答 keyword must not be followed by an object expression".


The problem is here:

 return false;

Your event handler is declared as void - you cannot return a bool. Just do return;


You can't return values from a void method. Change your statement to just return;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜