开发者

ASP Question - How to count # of characters?

开发者 https://www.devze.com 2022-12-18 05:12 出处:网络
Today is the very first day I\'ve ever even seen aspx, so, please bear with me... Basically, I want to determine if a string is empty.If it is empty, then I don\'t want anything to output, if it\'s

Today is the very first day I've ever even seen aspx, so, please bear with me...

Basically, I want to determine if a string is empty. If it is empty, then I don't want anything to output, if it's not, then I want to output the string itself.

<%= o_handler.renderDDesc()%> //This is the string itself... If this is empty, then I want I want nothing to print

I tried:

<%if (o_handler.renderDDesc().length() > 0) 开发者_StackOverflow{ %>
<%= o_handler.renderDDesc()%>
<%}%> 

But, that didn't seem to do anything. I didn't get an error, but it also didn't appear?


<%

string desc = o_handler.renderDesc();

if (!String.IsNullOrEmpty(desc)) { 
Response.Write(desc);
}

%> 


<%= !String.IsNullOrEmpty(o_handler.renderDDesc()) ? o_handler.renderDDesc() : ""%>


I would simply use a ternary operator as follows:

<%=( o_Handler.IsNullOrEmpty() ? string.Empty : o_handler.renderDDesc() ); %>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号