Lấy kích thước màn hình của client trong ASP.NET

1 1.8K 4
Lấy kích thước màn hình của client trong ASP.NET

Đang tải... (xem toàn văn)

Thông tin tài liệu

Lấy kích thước màn hình của client trong ASP.NET Bạn muốn xác định kích thước màn hình của client để dàn trang web tự động theo cấu hình. Các dòng code sau sẽ giúp bạn lấy độ rộng và cao của client và gửi trở lại về Server Chúng tôi sử dụng 2 tập tin start.aspx <html> <body onload=''storeWidthAndHeightToTheServer()''> <form id=''resolution'' method=''post'' action=''default.aspx''> </form> <script language=''javascript''> function storeWidthAndHeightToTheServer() with (document.getElementById('resolution')) { var InitStr; InitStr = ''default.aspx?ScreenWidth=''; InitStr += screen.width; InitStr += ''&ScreenHeight=''; InitStr += screen.height; action = InitStr; submit(); } } </script> </body> </html> default.aspx <html> <head> <script language=''C#'' runat=''server''> void Page_Load(object s, EventArgs e) { string width = HttpContext.Current.Request.QueryString[''ScreenWidth'']; string height = HttpContext.Current.Request.QueryString[''ScreenHeight'']; Session[''width''] = width; Session[''height''] = height; Label1.Text = ''Width= '' + width + '' Height= '' + height; } </script> </head> <body> <form runat=''server'' ID=''Form1''> <asp:Table Width=''100%'' Runat=''server'' ID=''Table1''> <asp:TableRow> <asp:TableCell HorizontalAlign=''Center''> <asp:Label ID=''Label1'' Runat=''server''></asp:Label> </asp:TableCell> </asp:TableRow> </asp:Table> </form> </body> </html> Bây giờ bạn có thể có các giá trị và lưu vào session và sử dụng các giá trị ở bất cứ đâu trong web application . Lấy kích thước màn hình của client trong ASP. NET Bạn muốn xác định kích thước màn hình của client để dàn trang web tự động theo cấu hình. Các. hình. Các dòng code sau sẽ giúp bạn lấy độ rộng và cao của client và gửi trở lại về Server Chúng tôi sử dụng 2 tập tin start.aspx <html> <body onload=''storeWidthAndHeightToTheServer()''>

Ngày đăng: 26/10/2013, 01:20

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan