开发者

How to format a date to be displayed in 2 lines?

I have a label called dateLabel that displays when did a user last time got logged in:

dateLabel.Text = "Sist gang logget inn: " + string.Format("{0:d}\n{0:T}", Session["LastLoginDate"].ToString());

What i want i to display the information in 2 different lines. In the first the date and in the one below the time.

  • How should i modify my code to achieve this?
  • Does it mind if i use a label, or maybe i should use another component?
  • Currently in that output there is a duplicate, but i don't understand why, how can i avoid that?

Current output:

How to format a date to be displayed in 2 lines?

Desired output:

How to format a date to be displayed in 2 lines?

Can someone开发者_运维技巧 give me some tips?


Replace \n with <br/> Also replace

Session["LastLoginDate"].ToString()

with

(DateTime)Session["LastLoginDate"]


dateLabel.Text = string.Format("Sist gang logget inn:{1}{0:d}{1}{0:T}",
                               Session["LastLoginDate"], 
                               "<br/>");


@sfrj as far as i know its not possible to wrap the text on asp:label control you can try a text box control instead read on the following link

http://geekswithblogs.net/StealThisCode/archive/2006/03/21/WrapLabels.aspx

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜