Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET HTML Webmatrix
@using Microsoft.Web.Helpers;
 
@{
    Page.Title = "orderReg";
    if(!WebSecurity.IsAuthenticated)
    {
       //navigate to login page
        Response.Redirect(App.PathUserLogin + "?returnUrl=" + Request.Url.LocalPath);
    }
    // Initialize page
    var FirstName = string.Empty;
    var LastName = string.Empty;
    int Gender = 1;
    int LangSelect = 1; 
    var Field = string.Empty;
    var Subject = string.Empty;
    bool FileValidator = true;
    var Description = string.Empty;
    List<string> lstFilePaths = new List<string>();
    Validation.RequireField("txtField", "specify ...");
    Validation.RequireField("txtSubject", "specify ...");
    // If this is a POST request, validate and process data
    if (IsPost && Validation.IsValid())
    {
        var db = Database.Open("Trans");
        //fetch User Details
        var UserProfileRow = db.QuerySingle("SELECT * FROM UserProfile WHERE Id = " + WebSecurity.CurrentUserId);
        Gender = Convert.ToInt32(UserProfileRow.Gender);
        FirstName = UserProfileRow.FirstName;
        LastName = UserProfileRow.LastName;
        LangSelect = Convert.ToInt32(Request.Form["LangSelect"]);
        Field = Request.Form["txtField"];
        Subject = Request.Form["txtSubject"];
        Description = Request.Form["txtDescription"];
        //validate file(s)
        lstFilePaths.Clear();
        for(int i = 0; i < Request.Files.Count; i++)
        {
            if(Request.Files[i].ContentLength == 0)
            {
                    FileValidator = false;
                    break;
            }
            else
            {
                lstFilePaths.Add(Request.Files[i].FileName);
            }
        }
        if(FileValidator == true)
        {
            //update db
            int AuditNum = 1000;
            if(db.QueryValue("SELECT COUNT(*) FROM OrderStatus") > 0)
            {
                AuditNum = db.QueryValue("SELECT MAX(AuditNum) FROM OrderStatus") + 1;
            }
            string ConcatFileNames = AuditNum.ToString() + "_";
            //upload file
            for(int i = 0; i < Request.Files.Count; i++)
            {
                var uploadedFile = Request.Files[i];
                var fileName = Path.GetFileName(uploadedFile.FileName);
                var SavedFileName = AuditNum.ToString() + "_" + fileName;
                var DirectorySavePath = Server.MapPath("~/App_Data/UploadedFiles/" + AuditNum + "/In/");
                var fileSavePath = Server.MapPath("~/App_Data/UploadedFiles/" + AuditNum + "/In/" + SavedFileName);// + FileExt);   
                Directory.CreateDirectory(DirectorySavePath);
                uploadedFile.SaveAs(fileSavePath);
                var ShortFileName = string.Empty;
                if(fileName.Length > 6)
                {
                    ShortFileName = fileName.Substring(0,6);
                }
                else
                {
                    ShortFileName = fileName;
                }
                ConcatFileNames += ShortFileName + "_";
            }
            //insert order status information
            db.Execute(@"
                INSERT INTO OrderStatus 
                (AuditNum, Price, Status, PricingTime, WordsNum, DeliveryTime) 
                VALUES (@0, @1, @2, @3, @4 , @5)", 
                AuditNum, null, App.strUnVisited, null, null, null);
            
            db.Execute(@"
                INSERT INTO OrderDetails 
                (FileName, Lang, Description, Time, UserId, Subject, Field, AuditNum) 
                VALUES (@0, @1, @2, @3, @4, @5, @6, @7)", 
                ConcatFileNames, LangSelect, Description, DateTime.Now, WebSecurity.CurrentUserId, Subject, Field, AuditNum );
            db.Close();
            db.Dispose();
            Session["Description"] = Description;
            Session["lstFilePaths"] = lstFilePaths;
            string SendingParams = "AuditNum=" + AuditNum + "&FirstName=" + FirstName + "&LastName=" + LastName 
            + "&Gender=" + Gender + "&LangSelect=" + LangSelect + "&Field=" + Field + "&Subject=" + Subject;
            Response.Redirect("~/Orders/OrderConf?" + SendingParams);
        }
    }
}
 
@if(IsPost && !Validation.IsValid() )
{
    <div id ="ErrorBorder">  
        <p>correvt...</p> <br/>
        @Html.ValidationSummary()
    </div>
}
 
<form method="post" action="" enctype="multipart/form-data">
    <fieldset>
        <legend>سفارش ترجمه</legend>
                
        <table class="InTheForm">
            <!--<caption>سفارش</caption>-->
            <tr>
                <th rowspan="2">lang</th>
                <td>
                    <input type="radio" name="LangSelect" value="1" @(LangSelect == 1 ? "checked = 'checked'" : "")/>e2p<br/>
                </td>
            </tr>
            <tr>
                <td>
                    <input type="radio" name="LangSelect" value="0" @(LangSelect == 0 ? "checked = 'checked'" : "")/>p2e
                </td>
            </tr>
            <tr>
                <th>field</th>
                <td>
                    <input type="text" name="txtField" value="@Field"/>
                    <span class="Star">*</span>
                </td>
                <td><div style="font-size: smaller">examples...</div></td>
            </tr>
            <tr>
                <th>subj</th>
                <td>
                    <input type="text" name="txtSubject" value="@Subject"/>
                    <span class="Star">*</span>
                </td>
            </tr>
            <tr>
                <th>files...</th>
                        
                <td>
                    @FileUpload.GetHtml(
                        initialNumberOfFiles:1,
                        allowMoreFilesToBeAdded:true,
                        includeFormTag:true,
                        uploadText:"Upload")    <!--upload button is hidden using CSS-->
                    @if (IsPost) {
                        if(FileValidator == true && Validation.IsValid())
                        {
                            <span>uploaded</span> <br/>
                        }
                        else if (FileValidator == false)
                        {
                            <span>error...</span> <br/>
                        }
                    }
                </td>
                        
            </tr>
            <tr>
                <th>commects</th>
                <td><textarea name="txtDescription" rows="5" style="width: 100%"></textarea></td>
            </tr>
            <tr>
                <td colspan="2" style="text-align: center"><input type="submit" value="send"/></td>
            </tr>
        </table>
    </fieldset>
</form>
 
 
I have got a form in my page which contains a file upload helper and a submit button (and some other controls). My page is working fine and the form can be submitted when browsed by firefox or chrome. But in ie when I press the submit button nothing happens (the form is not submitted to the server). What can cause this browser-specific problem?
Posted 6-Mar-13 22:17pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

If you set the includeFormTag as true in your FileUpload helper, it makes a new form into the form that you have already created.
 
Setting the parameter to false has the result of removing the unnecessary <form> tag and, furthermore, lifts the upload button that you hide with CSS.
 
Maybe this is the reason why IE doesn't work properly.
  Permalink  
v2
Comments
cs101000 at 8-Mar-13 5:09am
   
Yes! Thank you for helping me again. That was the point and it was really helpful. But why chrome and firefox dont have this problem? (my vote of 5)
Gianmaria Gregori at 8-Mar-13 16:42pm
   
There are a lot of differences between browser, mainly when the code isn't completely consistent.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 400
1 Sergey Alexandrovich Kryukov 329
2 Afzaal Ahmad Zeeshan 264
3 BillWoodruff 245
4 CPallini 195
0 OriginalGriff 5,560
1 DamithSL 4,476
2 Maciej Los 3,942
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,175


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 8 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100