P
Perry van Kuppeveld
Hi,
I would like to submit a form through scripting, and still retrieve the
click event on the server.
See code below to test some stuff.
Create a C# webapplication and replace the WebForm1 class with the code
below.
While running the program, give the textarea the focus and press enter. See
the dif with clicking submit.
public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
TextBox tb = new TextBox( );
tb.TextMode = TextBoxMode.MultiLine;
string script = "if (event.keyCode == 13) {
document.forms[0].submit(); return false; }";
tb.Attributes["onkeypress"] = script;
this.FindControl("form1").Controls.Add(tb);
Button b = new Button();
b.Text = "Submit";
b.Click +=new EventHandler(b_Click);
this.FindControl("form1").Controls.Add(b);
}
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
private void b_Click(object sender, EventArgs e)
{
Response.Write("Submit");
}
}
I would like to submit a form through scripting, and still retrieve the
click event on the server.
See code below to test some stuff.
Create a C# webapplication and replace the WebForm1 class with the code
below.
While running the program, give the textarea the focus and press enter. See
the dif with clicking submit.
public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
TextBox tb = new TextBox( );
tb.TextMode = TextBoxMode.MultiLine;
string script = "if (event.keyCode == 13) {
document.forms[0].submit(); return false; }";
tb.Attributes["onkeypress"] = script;
this.FindControl("form1").Controls.Add(tb);
Button b = new Button();
b.Text = "Submit";
b.Click +=new EventHandler(b_Click);
this.FindControl("form1").Controls.Add(b);
}
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
private void b_Click(object sender, EventArgs e)
{
Response.Write("Submit");
}
}