使用的html代码是
<input runat="server" id="SubmitButton" type="submit" value="submit" onserverclick="MySubmitHandler" /></p>
和c#代码是
protected void MySubmitHandler(object sender, EventArgs args)
{
ResultLabel.InnerText="Thanks for clicking :)";
}
和标签的代码是:
<label id="ResultLabel" style="font-family: Arial; font-size: 12px; text-decoration: blink; font-weight: bold; font-style: italic; font-variant: normal; color: #FF0000; background-color: #00FF00" runat="server" >[Result will be displayed here]</label>
答案 0 :(得分:0)
C#甚至可以在浏览器中运行吗?这是jQuery的解决方案:
HTML:
<input id="SubmitButton" type="button" value="submit" value="Click Me!"/>
<label id="ResultLabel" style="font-family: Arial; font-size: 12px; text-decoration: blink; font-weight: bold; font-style: italic; font-variant: normal; color: #FF0000; background-color: #00FF00" runat="server" >[Result will be displayed here]</label>
jQuery的:
<script>
$(function() {
$("#SubmitButton").click(function(e) {
$("#ResultLabel").text("Thanks for clicking :)");
});
});
</script>