user1144852
user1144852

Reputation: 265

How to write error message in a label?

I would like to display error msg in a label and for that I am using the code written below but it says "cannot convert type void to string."

 catch (Exception ex)
 {
     conn.Close();
     LblException.Text = Response.Write(ex.Message);
 }

Is there a work around for this?

Upvotes: 0

Views: 858

Answers (1)

Mephy
Mephy

Reputation: 2986

Response.Write returns void. What you want to be the text is ex.Message: LblException.Text = ex.Message;.

Upvotes: 4

Related Questions