This project has moved. For the latest updates, please go here.

Any sample for ASP.NET Webform?

Topics: General Discussion, Generals
Jun 8, 2012 at 6:11 PM

Please upload a sample for asp.net webform if possible.

I'm not familiar with MVC framework.

Thank you so much.

Coordinator
Jun 15, 2012 at 9:18 PM

In Asp.net WebForm you have only 1 Html Form and you can't have more.

You must put it in iFrame or new window with simple html

Web.config And Handlers directory are same. copy them from Mvc sample project

 

        $(function () {

            var GetProgressInfo = function (data) {
                return "<span class='green'>" + data.Percent + "%</span> - " + data.StatusText + " - <span class='blue'>Speed:" + data.Speed + "</span> - <span class='red'>Total:" + data.Total + "</span>";
            }

            var form = $("#AvatarForm");
            form.find("input").change(function () { form.submit() });
            form.ManageUpload(function (data) {
                form.find(".Status").html(GetProgressInfo(data));
                if (data.Status > 2) {
                    // Finish
                }

                switch (data.Status) {
                    case 3: //Completed
                        form.parent().find(".LogoPlace").css("background-image", "url(/Avatar/160/" + encodeURI(data.FileNameNoExt) + ".JPEG)");
                        break;
                    case 4: //Invalid data
                        form.find(".Status").html("Invalid data(crc).<br /> try agen please.");
                        break;
                    case 5: //User close the browser or ....
                        //User Canceled;
                        break;
                    case 6: //Validation faild.
                        switch (data.ValidateType) {
                            case 1: //File type validation
                                form.find(".Status").html(data.FileName + " is not a valid file for upload");
                                break;
                            case 2: //File size validation
                                form.find(".Status").html(data.FileName + " is too big for upload");
                                break;
                        }
                        break;
                }
            }, { statusPath: '<%=ResolveUrl("~/GetUploadStatus.axd")%>' });

            var form2 = $("#GalleryForm");
            form2.find("input").change(function () { form2.submit() });
            form2.ManageUpload(function (data) {
                form2.find(".Status").html(GetProgressInfo(data));
                if (data.Status > 2) {
                    // Finish
                }

                switch (data.Status) {
                    case 3: //Completed
                        form2.parent().find(".GalleryItem1").css("background-image", "url(/UserGallery/160/" + encodeURI(data.FileNameNoExt) + ".JPEG)");
                        form2.parent().find(".GalleryItem2").css("background-image", "url(/UserGallery/50/" + encodeURI(data.FileNameNoExt) + ".JPEG)");
                        break;
                    case 4: //Invalid data
                        form2.find(".Status").html("Invalid data(crc).<br /> try agen please.");
                        break;
                    case 5: //User close the browser or ....
                        //User Canceled;
                        break;
                    case 6: //Validation faild.
                        switch (data.ValidateType) {
                            case 1: //File type validation
                                form2.find(".Status").html(data.FileName + " is not a valid file for upload");
                                break;
                            case 2: //File size validation
                                form2.find(".Status").html(data.FileName + " is big for upload");
                                break;
                        }
                        break;
                }
            }, { statusPath: '<%=ResolveUrl("~/GetUploadStatus.axd")%>' });

            var form3 = $("#BigFileForm");
            form3.ManageUpload(function (data) {
                form3.find(".Status").html(GetProgressInfo(data));
                if (data.Status > 2) {
                    // Finish
                }

                switch (data.Status) {
                    case 3: //Completed
                        form3.parent().find(".DownloadLink").html("<a href='/Uploads/" + encodeURI(data.FileName) + "'>" + data.FileName + "</a>");
                        break;
                    case 4: //Invalid data
                        form3.find(".Status").html("Invalid data(crc).<br /> try agen please.");
                        break;
                    case 5: //User close the browser or ....
                        //User Canceled;
                        break;
                    case 6: //Validation faild.
                        switch (data.ValidateType) {
                            case 1: //File type validation
                                form3.find(".Status").html(data.FileName + " is not a valid file for upload");
                                break;
                            case 2: //File size validation
                                form3.find(".Status").html(data.FileName + " is big for upload");
                                break;
                        }
                        break;
                }
            }, { statusPath: '<%=ResolveUrl("~/GetUploadStatus.axd")%>' });


        });

 

 

    <fieldset>
        <legend>Avatar</legend>
        <div>
            <div class="LogoPlace" style="width: 160px; height: 160px; border: 1px solid #bbb;"></div>
            <form id="AvatarForm" method="post" action="<%= ResolveUrl("~/AvatarUpload.axd")%>" enctype="multipart/form-data">
                <label for="PictureFile">Select your file</label>
                <input type="file" id="PictureFile" name="PictureFile" />
                <small>(auto upload after select)</small>
                <div class="Status"></div>
            </form>
        
        </div>
    </fieldset>
    
    <fieldset>
        <legend>Gallery</legend>
        <div>
            <div class="GalleryItem1" style="width: 160px; height: 160px; border: 1px solid #bbb; float: left;"></div>
            <div class="GalleryItem2" style="width: 50px; height: 50px; border: 1px solid #bbb; float: left;"></div>
            <div style="clear: both;"></div>
            <form id="GalleryForm" method="post" action="<%=ResolveUrl("~/GalleryUpload.axd")%>" enctype="multipart/form-data">
                <label for="ImageFile">Select your file</label>
                <input type="file" id="ImageFile" name="ImageFile" />
                <div class="Status"></div>
            </form>
        
        </div>
    </fieldset>
    
    <fieldset>
        <legend>Big file uploader</legend>
        <div>
            <div class="DownloadLink"></div>
            <form id="BigFileForm" method="post" action="<%=ResolveUrl("~/BigFileUpload.axd")%>" enctype="multipart/form-data">
                <label for="BigFile">Select your file</label>
                <input type="file" id="BigFile" name="ImageFile" />
                <button type="submit">Send</button>
                <div class="Status"></div>
            </form>
        
        </div>
    </fieldset>