3

Given:

<button runat="server" id="btnNext">Next &gt;</button>

I need in my code behind the have the onclick event, but the onclick event in this case refers to clientonclick, I have to use the button HTML tag not ASP:button because ASP:Button renders as input which doesn't work with my CSS....

Any ideas?

For everyone saying change my CSS, here it is:

input[type=button], button {
    font-family: arial, sans-serif;
    font-size: 12px;
    font-weight: bold;
    margin: 0px;
    padding: 5px 20px 5px 20px;
    outline-width: 0;
    border: 1px solid #000;
    border-radius: 7px;
    -moz-border-radius: 7px;
    -webkit-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.5);
    -moz-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.5),
        inset 0px 1px 0px rgba(255, 255, 255, 0.5);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5),
        inset 0px 1px 0px rgba(255, 255, 255, 0.5);
    -webkit-transition: background-color 0.2s ease-in-out,
        color 0.2s ease-in-out,
        -webkit-box-shadow 0.2s ease-in-out;
    -moz-transition: background-color 0.2s ease-in-out,
        color 0.2s ease-in-out,
        -moz-box-shadow 0.2s ease-in-out;
    -o-transition: background-color 0.2s ease-in-out,
        color 0.2s ease-in-out,
        box-shadow 0.2s ease-in-out;
    background-image: -webkit-gradient(linear, left top, left bottom,
        color-stop(0.0, rgba(255, 255, 255, 0.8)),
        color-stop(0.01, rgba(255, 255, 255, 0.6)),
        color-stop(0.4, rgba(255, 255, 255, 0.3)),
        color-stop(0.4, rgba(255, 255, 255, 0.2)),
        color-stop(1.0, rgba(255, 255, 255, 0.0)));
    background-image: -moz-linear-gradient(top,
        rgba(255, 255, 255, 0.6) 0%,
        rgba(255, 255, 255, 0.3) 40%,
        rgba(255, 255, 255, 0.2) 40%,
        rgba(255, 255, 255, 0.0) 100%);
    background-color: #444;
    color: #fff;
    text-shadow: rgba(0, 0, 0, 0.5) 0px -1px 0px;
}
input[type=button]:hover, input[type=button]:focus, button:hover, button:focus {
    -webkit-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.9);
    -moz-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.9),
        inset 0px 1px 0px rgba(255, 255, 255, 0.5);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.9),
        inset 0px 1px 0px rgba(255, 255, 255, 0.5);
    background-color: #666;
    color: #fff;
}
input[type=button]:active, button:active {
    background-color: #222;
    color: #ccc;
    -webkit-transition-duration: 0.0s;
    -moz-transition-duration: 0.0s;
    -o-transition-duration: 0.0s;
}

If I assign this to an input it doesn't show all the effects.

2
  • You can't use CSSClass in your ASP button to define your CSS? Commented Jan 28, 2011 at 15:26
  • See edit, not all effects work unless it's styled to a button element Commented Jan 28, 2011 at 15:32

2 Answers 2

4

Change your CSS - the problem isn't with asp.net but its with your stylesheet. Its really not that hard to stick 'input' after 'button' in your stylesheet

Sign up to request clarification or add additional context in comments.

4 Comments

The css I'm using doesn't work on input elements, only the button element.
Look at edit, a lot of those CSS effects don't work with a <input> tag
That looks like a lot of nasty CSS, what does it actually do? Look here stackoverflow.com/questions/469059/… button seems to have a few problems of its own. Why go against the flow? Input is the way to go.
You are right, with much less CSS and <asp:button> I can style it 90% of what I want.
1

The <button> element will be translated into an HtmlButton instance in your code-behind. That class exposes a server-side ServerClick event that you can use for your purposes:

<button runat="server" id="btnNext"
    OnServerClick="btnNext_Click">Next &gt;</button>

protected void btnNext_Click(object sender, EventArgs e)
{
    // Handle the click event...
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.