CS0029: Cannot implicitly convert type 'void' to 'object'

Posted by perfectchourasia-9163 under ASP.NET on 11/21/2011 | Points: 10 | Views : 5352 | Status : [Member] | Replies : 6
if (Page.IsValid)
{
string from = "sandeepchrs@yahoo.com";
string to = txtemailto.Text.ToString().Trim();
string subject = txtmailsubject.Text.ToString().Trim();
string body = txtemailmsg.Text.ToString().Trim();
string filename = Path.GetFileName(FileUpload1.FileName);
string fileAttach = FileUpload1.SaveAs(Server.MapPath("Attachement") + "\\" + filename); ;
sendmail.SendMailMessage(from, to, subject, body, fileAttach);

}

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/



Responses

Posted by: Blessyjees on: 11/21/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,

what is your problem. Please correct your question with clear information.

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

perfectchourasia-9163, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 11/21/2011 [Member] Starter | Points: 25

Up
0
Down

I have made emailsend class which is in app_code
I m passing parameter to that but here

string fileAttach = FileUpload1.SaveAs(Server.MapPath("Attachement") + "\\" + filename);
i m getting error.

CS0029: Cannot implicitly convert type 'void' to 'string'

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

perfectchourasia-9163, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 11/21/2011 [Member] Starter | Points: 25

Up
0
Down

I have made emailsend class which is in app_code
I m passing parameter to that but here

string fileAttach = FileUpload1.SaveAs(Server.MapPath("Attachement") + "\\" + filename);
i m getting error.

CS0029: Cannot implicitly convert type 'void' to 'string'

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

perfectchourasia-9163, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Blessyjees on: 11/21/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,

This error means Fileupload1.SaveAs(..) does not return any value. If you remove "string fileAttach=" it will working properly.

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

perfectchourasia-9163, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 11/21/2011 [Member] Starter | Points: 25

Up
0
Down
ya but then how i will send the path to class to for attachment.

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

perfectchourasia-9163, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Blessyjees on: 11/22/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,

You can store this as string like

string fileAttach =Server.MapPath("Attachement") + "\\" + filename; 


Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

perfectchourasia-9163, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response