http://blog.csdn.net/lmaohuanl/article/details/6792057
- <! DOCTYPE HTML public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd ">
- "http://www.w3.org/1999/xhtml" >
- <title></title>
- <!--ExtJs4.0 official download ExtJS style file--
- <link href="extjs/resources/css/ext-all.css" rel="stylesheet" type="Text/css"/>
- <!--ExtJs4.0 official download ExtJS file--
- <script src="extjs/ext-all.js" type="Text/javascript" ></script>
- <script language="javascript" type="Text/javascript" >
- function Login_click (b) {
- //1. Get the form panel
- var loginformpanel=ext.getcmp ("Loginformpanel");
- //2. Get the form inside it through the Panel object
- var form = Loginformpanel.getform ();
- //3. Before submitting, determine if the form input is wrong
- if (!form.isvalid ()) {
- return;
- }
- //4. Invoking the submitted method, submitting the form
- Form.submit ({
- Waitmsg:"Submitting data to the server",
- URL:"extjs1.aspx",
- Success: function (f, a) {
- Ext.MessageBox.alert ("hint", "your details are as follows:<br/> user name:" + a.result.name + "<br/> Password:" + A.result.password + "<br/> The number of images you uploaded is:"
- + A.result.filecount);
- },
- Failure: function (f,a) {
- Ext.MessageBox.alert ("hint", a.result.msg);
- }
- });
- }
- Ext.onready (function () {
- var txtusername = New Ext.form.field.Text ({
- Fieldlabel: "user name",
- LABELWIDTH:50,
- Margin: "0 5 0",
- Allowblank: false,
- Blanktext: "user name cannot be empty",
- Name: "txtUserName"
- });
- var txtuserpassword = New Ext.form.field.Text ({
- Fieldlabel: "password",
- LABELWIDTH:50,
- Margin: "5 0 5 0",
- InputType: "password",
- Allowblank: false,
- Blanktext: "Password cannot be empty",
- Name: "Txtuserpassword"
- });
- var file = New Ext.form.field.File ({
- Fieldlabel:"Please select a picture",
- ButtonText:"Browse",
- Regex:/^.+\. (jpg|png|gif) $/,
- Regextext:"You can only select pictures in jpg,png,gif format"
- });
- var win = New Ext.window.Window ({
- Title: "Submit data--Login",
- HEIGHT:200,
- WIDTH:350,
- Layout: "Fit",
- Items: [
- {xtype: "Form", Frame: true, layout: {type: "VBox", align: "center"},
-
- Items: [txtUserName, Txtuserpassword, file], buttons: [{text: "Login",
- Handler:login_click}], ID: "loginformpanel"}
- ]
- });
- Win.show ();
- });
- </script>
- <body>
- </body>
-
- Using System;
- Using System.Collections.Generic;
- Using System.Linq;
- Using System.Web;
- Using System.Web.UI;
- Using System.Web.UI.WebControls;
- Public partial class Extjs1:System.Web.UI.Page
- {
- protected void Page_Load (object sender, EventArgs e)
- {
- System.Threading.Thread.Sleep (3000);
- String name = request.form["txtUserName"];
- string password = request.form["Txtuserpassword"];
- //.............................
- int pointindex=request.files[0]. Filename.lastindexof (".");
- string lastname=request.files[0]. Filename.substring (PointIndex);
- string fileName = new Random (). Next (10000). ToString ();
- string path = Server.MapPath ("") + "/" + FileName + lastName;
- Request.files[0]. SaveAs (path);
- Response.Write ("{success:true,msg: ' success ', Name: '" +name+"', Password: '" +password+"', FileCount: '" + request.files.count+"'}");
- Response.End ();
- }
- }
Go: asp.net+extjs4.0+ form submission Submit, upload image to server