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

前端 未结 8 1477
忘了有多久
忘了有多久 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.

提交回复
热议问题