开发者

Code Behind file event handler with c#

开发者 https://www.devze.com 2023-03-29 16:37 出处:网络
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 mes

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

精彩评论

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