c# how to get element width
Is there a way that I can do the equivilant of开发者_Go百科 jQuery's
var myElementWidth = $('.class').width;
in c# and store it as a variable to use later.
Any pointers would be welcome.
As some comments are pointing, if positioning and sizing happens in client-side, C#, server-side code will never know about actual dimension and location of some given element.
But if this width is very important for your Web application, maybe you can set this value just after client renders the page with some asynchronous operation.
I'd argue that one of simpler ways of doing it would be implementing ICallbackHandler
interface:
- http://msdn.microsoft.com/en-us/library/ms178208.aspx
This will allow you to take some value from the client-side and save it in the server without postbacks, so you can store it in some session-state item.
精彩评论