How to show intro text only in news website (asp.net mvc) -
i have function in view:
@helper truncate(string input, int length) { if (input.length<=length) { @input; } else { @input.substring(0,length)@:... } } if write @truncate("some word",50) => worked write @truncate(item.description, 50) => error: object reference not set instance of object.
please help me prepare problem or show me way show intro text in site
thanks!
if input null, error input.length , input.substring lines. should check, if not null.
@helper truncate(string input, int length) { if(input == null) { // } else { if (input.length <= length) { @input; } else { @input.substring(0,length)@:... } } } edit (after comment)
you can use:
input = regex.replace(input , "<.*?>", string.empty); note: html.raw returns markup not html encoded.
asp.net asp.net-mvc
No comments:
Post a Comment