ASP. NET is like Web Form, and like drag controls (4)

Source: Internet
Author: User

ASP. NET: Like Web Form, or Drag Control (3). We have a comprehensive function to insert data into the Form, and it is easier for the GridView to display data. However, the customer is absolutely unable to accept a page that is so arrogant and so crude: (although from a technical point of view, this page already has some functionality ......)

First, the first problem is that the table length and width are different in size. We can solve this problem through CSS:

First, we need to add a client CSS class to the GridView so that we can use it in CSS and add the property: CssClass = "commodity_data"

The image cell is special. We add two client CSS classes to it: HeaderStyle-CssClass = "image" ItemStyle-CssClass = "image"

Then we use CSS to change the style:

Copy to ClipboardReference: [www.bkjia.com] table. commodity_data
{
Width: 100%;
}
Table. commodity_data tr th
{
Width: 15em;
Background-color: Gray;
}
Table. commodity_data tr td
{
Width: 15em;
Text-align: center;
}
Table. commodity_data tr td. image
{
Width: auto;
}
Table. commodity_data tr th. image
{
Width: auto;
}

After adding the following style, the page looks much more comfortable. However, images of different sizes still affect the visual effect. Therefore, we need to scale them to a proper size using JavaScript. We want to limit the length and width to X and maintain the aspect ratio. First, we must use a x container to restrict the image and rewrite the img code:

Copy to ClipboardReference: [www.bkjia.com] <asp: Image ID = "Image" runat = "server"
ImageUrl = '<% # Eval ("id", "\ CommodityImage. aspx? Id = {0} ") %> '/>

Rewrite:

Copy to ClipboardReference content: [www.bkjia.com] <div style = "text-align: center; line-height: 100px; font-size: 12px; height: 100px; width: 100px; overflow: hidden; ">
<Asp: Image ID = "Image" onreadystatechange = "OnImageReady. apply (this, arguments);" runat = "server"
ImageUrl = '<% # Eval ("id", "\ CommodityImage. aspx? Id = {0} ") %> '/>
</Div>

The size of the image is limited, but the cut seems uncomfortable. At this time, we need JavaScript to do the following:

Copy to ClipboardReference content: [www.bkjia.com] <div style = "text-align: center; line-height: 100px; font-size: 12px; height: 100px; width: 100px; overflow: hidden; ">
<Asp: Image ID = "Image" onreadystatechange = "OnImageReady. apply (this, arguments);" runat = "server"
ImageUrl = '<% # Eval ("id", "\ CommodityImage. aspx? Id = {0} ") %> '/>
</Div>

  • 2 pages in total:
  • Previous Page
  • 1
  • 2
  • Next Page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.