c# - If property at session not null or default value, run/print javascript Razor ASP.NET MVC -


how print javascript when accessing model session , property value not empty @ razor?

this code:

@{ arm.models.lanidmodel lanidmodel = (lanidmodel)httpcontext.current.session["sesslanidmodel"]; }}   @if(lanidmodel.lanid!=0 && lanidmodel.name != string.empty &&  !string.isnullorempty(lanidmodel.email)){            @html.raw("$('.input-switch-disabled').removeattr('disabled');");         } 

and when run on browser, got this:

 @if(lanidmodel.lanid!=0 && lanidmodel.name != string.empty && !string.isnullorempty(lanidmodel.email)){ line 98:            @html.raw("$('.input-switch-disabled').removeattr('disabled');"); line 99:         } 

is able do?

wrap javascript in script tags.

@html.raw("<script>$('input-switch-disabled').removeattr('disabled');</script>"); 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -