-1

"Hi I am new to MVC so sorry if this sounds silly ,but please could anyone tell me how to set javascript parameters as keys in viewdata or tempdata.. the problem is that i want to set display property of certain elements in my view any want them to persist after a post back following is the code for same .

function VisibleColunms(Cssclass) {
    $("."+Cssclass).toggle(500);
    if (@Viewdata[Cssclass] != null && @Viewdata[Cssclass]  != "none") {
      @Viewdata[Cssclass] ="block"

    } else {
        @Viewdata[Cssclass] = "none"

    }      
}

please suggest any way around if possible for the same ,NOTE: I cannot user hidden fields coz of updating target div using ajax .thank you in advance.

1 Answers1

0
    var data = @Html.Raw(Json.Encode(@ViewData["LoadData"]));

it will help you for converting viewdata or temp data to javascript object or javascript value. but the thing is it perfoctally work in views once try in script file also.