PDA

View Full Version : I can't submit a form ::>_<::



ypfbkg
5 Aug 2010, 4:08 AM
Dear all,
this is html code:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>04.form</title>
<link rel="stylesheet" type="text/css" href="ExtJs/resources/css/ext-all.css" />
<script type="text/javascript" src="ExtJs/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ExtJs/ext-all.js"></script>
<script type="text/javascript">
Ext.onReady(function(){

var form = new Ext.form.FormPanel({
defaultType: 'textfield',
labelAlign: 'right',
title: 'form',
labelWidth: 50,
frame:true,
width: 220,
url: 'testsubmit.aspx',

items: [{
fieldLabel: 'test',
name: 'text'
}],
buttons: [{
text: 'submit',
handler: function() {
Ext.getDom(form).form.submit({
success:function(form, action){
Ext.Msg.alert('message', action.result.msg);
},
failure:function(){
Ext.Msg.alert('Error','Error');
}
});
}
}]
});
form.render("form");

});
</script>
</head>
<body>
<div id="form" style="margin:100px;"></div>
</body>
</html>
and this is my asp.net (C#) code, it only request["text"] and show it.
asp.net code

protected void Page_Load(object sender, EventArgs e)
{
if (Request.Params["text"] != null)
{
Response.Write(Request.Params["text"]);
Response.End();
}
Response.Write("success:true");
Response.End();
}when I click submit button, it never return "success" (always alert('Error' , 'Error')
and I set a broken point in testsubmit.aspx, it never run there.

what can I do, please help. Thanks.:-/

Condor
5 Aug 2010, 5:33 AM
Ext.getDom(form).form? That would return the <form> element!

You want:

form.getForm().submit({...});

Also, your server should return valid JSON, e.g.

{"success": true}
ps. This is best created using a JSON library and not by building the string yourself.