c# - Above show if there is success in Update -


this how i'm sitting in problem find out if true or false,

it true, move content false stop now.

that should able show text , simultaneously refresh page user can not throw content again. , displaying content true.

uploadsuccesbesked.cs

    public class uploadsuccesbesked {      public class validationresponse     {         public string trueindhold { get; set; }         public string tekst { get; set; }     }      public static validationresponse uploadindhold(string trueindhold)     {          validationresponse uploadindhold = new validationresponse();          int load = 3;         if (trueindhold == "succes")         {             uploadindhold.tekst = "<div class='alert alert-success'><strong>succes - jubbiii!!!</strong> der kom ingen fejl.!</div>";             httpcontext.current.response.addheader("refresh", load + ";url=?opdater=true");             return uploadindhold;         }         else if (trueindhold == "error")         {             uploadindhold.tekst = "<div class='alert alert-danger'><strong>fejl!!</strong> der er sket en fejl, kontakt os hvis det sker igen!</div>";             httpcontext.current.response.addheader("refresh", load + ";url=?opdater=false");             return uploadindhold;         }         return null;     } } 

eidtpassword.aspx.cs

if (uploadsuccesbesked.uploadindhold("succes"))         {             panelindhold.visible = true;             literalbesked.text = /*tekst come here*/;         } 

error message:

cannot implicitly convert type 'uploadsuccesbesked.validationresponse' 'bool'

the reason have written text come here, example in success, text in danish become listed here.

this signature of method:

public static validationresponse uploadindhold(string trueindhold) //            ^^^^^^^^^^^^^^^^^^ 

and underlined part return type. method returns object of type (or null).

in check, this:

if (uploadsuccesbesked.uploadindhold("succes")) 

this tries convert return value of method (which validationresponse object per above) bool, because if statements expect boolean value condition. of course not work.

what should instead check whether return value null. , if save return value, can reuse text:

validationresponse result = uploadsuccesbesked.uploadindhold("succes"); if (result != null) {     panelindhold.visible = true;     literalbesked.text = result.tekst; } 

Comments