您的位置:首页 > 编程语言 > ASP

asp net中的服务器按钮方式提交数据

2011-06-18 17:35 239 查看
在aspx页面中:

<div>

关键字:

<asp:TextBox ID="txtsearchKey" runat="server"></asp:TextBox>

<asp:ImageButton ImageUrl="~/manage/images/btn_search.gif" ID="btnSearch" runat="server" OnClick="btnSearch_Click" />

</div>

点击ImageButton按钮就会触发服务器事件,在aspx.cs中代码如下:

protected void btnSearch_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("ProductManage.aspx?searchkey=" + Server.UrlEncode(txtsearchKey.Text));
}

就是执行btnSearch_Click里面的方法,Response.Redirect形式跳转,Server.UrlEncode是对用户输入的监控,这样就会更加安全。

让我们一起说:

It is so easy!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐