How to programmatically measure string pixel width in ASP.NET?

前端 未结 8 1443
忘了有多久
忘了有多久 2020-12-19 03:06

How do you get the size of a string? In Windows Forms it\'s easy, I just use graphics object and then MeasureString function. In ASP.NET I\'m not sure how to do this.

相关标签:
8条回答
  • 2020-12-19 03:59

    If you are using JQuery, see this answer

    Determine Pixel Length of String in Javascript/jQuery?

    I'm sure if not you can work something similar.

    0 讨论(0)
  • 2020-12-19 04:01

    You can use the Length property on a string as follows:

    http://www.dotnetperls.com/string-length

    0 讨论(0)
提交回复
热议问题