Go: asp.net+extjs4.0+ form submission Submit, upload image to server

Source: Internet
Author: User

http://blog.csdn.net/lmaohuanl/article/details/6792057

  1. <! DOCTYPE HTML public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd ">
  2. "http://www.w3.org/1999/xhtml" >
  3. <title></title>
  4. <!--ExtJs4.0 official download ExtJS style file--
  5. <link href="extjs/resources/css/ext-all.css" rel="stylesheet" type="Text/css"/>
  6. <!--ExtJs4.0 official download ExtJS file--
  7. <script src="extjs/ext-all.js" type="Text/javascript" ></script>
  8. <script language="javascript" type="Text/javascript" >
  9. function Login_click (b) {
  10. //1. Get the form panel
  11. var loginformpanel=ext.getcmp ("Loginformpanel");
  12. //2. Get the form inside it through the Panel object
  13. var form = Loginformpanel.getform ();
  14. //3. Before submitting, determine if the form input is wrong
  15. if (!form.isvalid ()) {
  16. return;
  17. }
  18. //4. Invoking the submitted method, submitting the form
  19. Form.submit ({
  20. Waitmsg:"Submitting data to the server",
  21. URL:"extjs1.aspx",
  22. Success: function (f, a) {
  23. 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:"
  24. + A.result.filecount);
  25. },
  26. Failure: function (f,a) {
  27. Ext.MessageBox.alert ("hint", a.result.msg);
  28. }
  29. });
  30. }
  31. Ext.onready (function () {
  32. var txtusername = New Ext.form.field.Text ({
  33. Fieldlabel: "user name",
  34. LABELWIDTH:50,
  35. Margin: "0 5 0",
  36. Allowblank: false,
  37. Blanktext: "user name cannot be empty",
  38. Name: "txtUserName"
  39. });
  40. var txtuserpassword = New Ext.form.field.Text ({
  41. Fieldlabel: "password",
  42. LABELWIDTH:50,
  43. Margin: "5 0 5 0",
  44. InputType: "password",
  45. Allowblank: false,
  46. Blanktext: "Password cannot be empty",
  47. Name: "Txtuserpassword"
  48. });
  49. var file = New Ext.form.field.File ({
  50. Fieldlabel:"Please select a picture",
  51. ButtonText:"Browse",
  52. Regex:/^.+\. (jpg|png|gif) $/,
  53. Regextext:"You can only select pictures in jpg,png,gif format"
  54. });
  55. var win = New Ext.window.Window ({
  56. Title: "Submit data--Login",
  57. HEIGHT:200,
  58. WIDTH:350,
  59. Layout: "Fit",
  60. Items: [
  61. {xtype: "Form", Frame: true, layout: {type: "VBox", align: "center"},
    1. Items: [txtUserName, Txtuserpassword, file], buttons: [{text: "Login",
    2. Handler:login_click}], ID: "loginformpanel"}
    3. ]
    4. });
    5. Win.show ();
    6. });
    7. </script>
    8. <body>
    9. </body>
      1. Using System;
      2. Using System.Collections.Generic;
      3. Using System.Linq;
      4. Using System.Web;
      5. Using System.Web.UI;
      6. Using System.Web.UI.WebControls;
      7. Public partial class Extjs1:System.Web.UI.Page
      8. {
      9. protected void Page_Load (object sender, EventArgs e)
      10. {
      11. System.Threading.Thread.Sleep (3000);
      12. String name = request.form["txtUserName"];
      13. string password = request.form["Txtuserpassword"];
      14. //.............................  
      15. int pointindex=request.files[0].  Filename.lastindexof (".");
      16. string lastname=request.files[0].  Filename.substring (PointIndex);
      17. string fileName = new Random (). Next (10000).  ToString ();
      18. string path = Server.MapPath ("") + "/" + FileName + lastName;
      19. Request.files[0]. SaveAs (path);
      20. Response.Write ("{success:true,msg: ' success ', Name: '" +name+"', Password: '" +password+"', FileCount: '" +  request.files.count+"'}");
      21. Response.End ();
      22. }
      23. }

Go: asp.net+extjs4.0+ form submission Submit, upload image to server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.