?
Solved

ASP.net Stretch button an extra bit

Posted on 2014-03-01
2
Medium Priority
?
404 Views
Last Modified: 2014-03-01
Hi

I have buttons on my ASP.net site, whose text values are assigned on page load.
I haven't set the height and width properties so that they stretch automatically to fit the text.
I would like them to stretch a bit further than they do. Is it possible to do this?
0
Comment
Question by:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 2000 total points
ID: 39897356
I think what you're looking for is left and right padding in CSS.

When I add a button to a page, it's rendered as <input type="submit" ...> which is what you can target with CSS.

You will usually not want to target all buttons, maybe every button in a certain div which is what I show below.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title> EE Q_28377703 </title>
    <style type="text/css">
        div.new input[type=submit]
        {
            background-color: lightblue;
            padding-left: 50px;
            padding-right: 50px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" Text="Narrow" />
        <asp:Button ID="Button2" runat="server" Text="Really Really Wide" />
    </div>
    <div class="new">
        <asp:Button ID="Button3" runat="server" Text="Narrow" />
        <asp:Button ID="Button4" runat="server" Text="Really Really Wide" />
    </div>
    </form>
</body>
</html>

Open in new window

capture
If you do want all buttons to be targeted, just leave out "div.new" on line 5.

If it doesn't work or you need help targeting the right buttons, please post the generated code from your page (use 'view source' in the browser).

Another option would be to use the CssClass attribute on your buttons specifying a certain class and use that in your CSS.
    <style type="text/css">
        .MyClass
        {
            background-color: lightblue;
            padding-left: 50px;
            padding-right: 50px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" Text="Narrow" CssClass="MyClass" />
        <asp:Button ID="Button2" runat="server" Text="Really Really Wide" CssClass="MyClass" />
    </div>

Open in new window

0
 

Author Closing Comment

by:Murray Brown
ID: 39897714
Thanks very much
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question