Hello everyone,
I am using VSTS 2008 + C# + .Net 3.5 + IIS 7.0 + ASP.Net to develop a web application. The web application has an aspx page called default.aspx. And I want to implement the effect that when user press the enter key of keyboard, it is the same effect of press button "Action". Any ideas how to implement?
Here is the default.aspx file,
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<script type="text/javascript">
function requery() {
var query = location.search.substring(1);
var pairs = query.split("&");
var param1Value = document.getElementById("txtParam1").value;
url = "/Default.aspx?param1=" + param1Value;
for (var i = 0; i < pairs.length; ++i) {
var pair = pairs[i];
if ((pair.indexOf("param1") != 0) && (pair.length > 0)) {
url += "&" + pair;
}
}
location.href = url;
}
</script>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtParam1" runat="server"></asp:TextBox>
<input type="button" value="Action" onclick="requery()" />
</div>
</form>
</body>
</html>
Here is the code behind file default.aspx.cs,
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
txtParam1.Text = Request.QueryString["param1"];
}
}
}
thanks in advance, George