开发者

What is the correct way to show text in a button?

开发者 https://www.devze.com 2022-12-20 19:00 出处:网络
How do I display text for a button without going between the <button></button> tags? 开发者_如何学C<button id=\"btnTest\" >Need Text in button tag!</button>

How do I display text for a button without going between the <button></button> tags?

开发者_如何学C<button id="btnTest" >Need Text in button tag!</button>


I think you may have meant to ask for this :

<input type="submit" value="Text on button" />
<input type="button" value="And again" />


If you're doing it in ASP.net, use the asp button:

<asp:Button id="btnTest"
           Text="Need Text In button Tag"
           OnCommand="CommandBtn_Click" 
           runat="server"/>


You should use the input tag. The benefit of this is that the value of the button is also passed to the server along with the the contents of the form. This way on the server you can determine which button was pressed on the form. So say for example, you had a submit and a delete button. They would both be inputs with a type of 'submit' but their values would differ and so when it posts back, you can check the value of btnSubmit

Just remember that

<input type="submit" id="btnSubmit" value="text here" />

and

<button type="submit" id="btnSubmit">text here</button>

will look different so you don't want to mix the two in the same form :)

0

精彩评论

暂无评论...
验证码 换一张
取 消