Question:

How can I combine an image button with a text property in ASP.NET?

by  |  earlier

0 LIKES UnLike

I currently have a image button that has the text as part of the image. This does not work good when I adjust the size in the browser. So I want to make the text as actual text and not an image on it. But image button does not have a text property (duh) and the button control does not allow fancy looks or images for background colors. Any help is appreciated.

 Tags:

   Report

2 ANSWERS


  1. You don't even need code behind...Just use this code....It basically hides the default button appearance so you can put the text on there.  I even added some mouse over events for you.  Should get you started.

    Goodluck

    For some reason yahoo truncates the text..the line that ends with ".clas..." is supposed to say "className"

    <script type="text/javascript">

            //ADD BORDERS ON THE MOUSE OVER EVENT AND CHANGE THE CURSOR

            function OnMouseOver()

            {

                document.getElementById('spanMain').clas... = 'spanHover';      

            }

            function OnMouseOut()

            {

                document.getElementById('spanMain').clas... = 'spanNormal';

            }

        </script>

        <style type="text/css">

            .spanNormal,

            .spanHover,

            .spanGeneric

            {        

                background-image:url('SomeImage.jpg');

                background-repeat:no-repeat;

                height:26px;

            }

             .spanNormal

            {

                border:solid 3px transparent;

            }

            .spanHover

            {

             border: solid 3px DarkGray;

             cursor:pointer;    

            }

        </style>

            <span id="spanMain" onmouseover="OnMouseOver()" onmouseout="OnMouseOut()" class="spanNormal">          

               <asp:Button BackColor="Transparent" BorderColor="Transparent" BorderStyle="None" ID="btnText" runat="server" Width="75px" Height="20px" Font-Bold="true" Font-Size="15px" Text="YourText" />

            </span>


  2. You will need to use both an image button and a Link button. The image button on its own will not suffice.

    Hope this works.

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.