• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 397
  • Last Modified:

Spacing between images in a table cell (ASP.NET C#)

I have multiple ImageButtons in a single cell of table in my .aspx page. The ImageButtons and the table are generated dynamically.

Please tell me how I can change the spacing between them.
0
dshrenik
Asked:
dshrenik
  • 4
  • 2
3 Solutions
 
OBonioCommented:
CSS is your best bet.  Using CssClass of the ImageButton, give them a class with left-padding: 5px;.
0
 
dshrenikAuthor Commented:
If possible, can you give the some sample code? Thanks!
0
 
dshrenikAuthor Commented:
The following code is not working:
    <style>
    ImageButton {
        left-padding: 15px;
    }
    </style>

Open in new window

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
dshrenikAuthor Commented:
Also, can you tell me where I need to add this code in my .aspx page?
When I add it inside a ContentPlaceHolder, it says that "Element 'Style' cannot be nested within element 'div".
0
 
vinodchCommented:
below is the code which may helps you, provide margin for image

<head runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript" src="Js/jquery.min.js"></script>
    <style type="text/css">
    .imgMargin
    {
    margin-left:3px;
    margin-right : 3px;
    }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="gvData" OnRowDataBound="gvData_RowDataBound" AutoGenerateColumns="false" runat="server">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <img src="images/image1.jpg" class="imgMargin" />
                    </ItemTemplate>
                   
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
    </div>
    </form>
</body>
0
 
vinodchCommented:
place style inside head tag
0
 
dshrenikAuthor Commented:
Great. Thanks!

Just a comment about assigning class for dynamically created ImageButtons.
The following code is required:
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now