Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
HTML
@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

1 solution

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.
 
Share this answer
 
v2
Comments
cs101000 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 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900