请教asp.net中的button属性OnClick的事件触发

来源:百度知道 编辑:UC知道 时间:2024/06/08 12:49:11
<tr>
<td style="width: 105px; height: 25px;">
分类名称:</td>
<td align="left" style="width: 190px; height: 25px;">
<asp:TextBox ID="tbName" runat="server" Width="183px" TextMode=SingleLine Enabled=true>

%>></asp:TextBox></td>
<td style="height: 25px" >
<asp:Button ID="btnADD" runat="server" Text="添加分类" Width="101px" OnClick="OnClick01" /></td>
</tr>

如果做验证的话你可以直接在验证控键里做。
比如:
<asp:RegularExpressionValidator ID="revJob" runat="server" ErrorMessage="请输入1-10的字符!"
ControlToValidate="txtJob" ValidationExpression="^[\u4e00-\u9fa5]{0,10}$" Display="Dynamic"></asp:RegularExpressionValidator>

<asp:Button ID="btnOther" runat="server" Text="选定职位" OnClick="btnOther_Click" Width="80px" Height="25px" />

alert("It's no empty");
是javascript语句;
应该这么写
Response.Write("<script>alert('It's no empty');</script>");
这个是对的
protected void OnClick(object sender, EventArgs e)

{

if (tbName.text== "")
{
Response.Write("<script>alert('It's no empty');</script>");
return false;