Advertisement
locnhse61312

Untitled

Nov 26th, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.37 KB | None | 0 0
  1.   @*
  2. hien thi views *@
  3. <div class="form-group">
  4.                                     <label class="col-sm-3 col-sm-offset-1 control-label no-padding-right">
  5.                                         Hình Ảnh</label>
  6.                                     <div class="col-sm-8">
  7.                                         <div class="btn-group">
  8.  
  9.                                             <input type="hidden" name="PicURL" id="PicURL" readonly="readonly" value="@Model.PicURL"/>
  10.                                             <a class="btn btn-success btn-small" id="addFile"><i class="icon-plus icon-white"></i></a>
  11.                                             <input type="button" value="Đăng hình" class="btn btn-info btn-small" id="uploadButton" onclick="UploadImage()" />
  12.                                             <br />
  13.  
  14.                                         </div>
  15.                                     </div>
  16.                                 </div>
  17.  
  18. @ *Nut hien thi upload *@
  19.    @using (Html.BeginForm("UploadImage", "Product", FormMethod.Post,
  20.     new
  21.     {
  22.         enctype = "multipart/form-data",
  23.         id = "ImgForm",
  24.         name = "ImgForm",
  25.         target = "UploadTarget"
  26.     }))
  27.         {
  28.             <input type="file" id="imageFile" name="imageFile" style="display: none" />
  29.                    
  30.         }
  31.  
  32.         <iframe id="UploadTarget" name="UploadTarget" onload="UploadImage_Complete();" style="position: absolute; left: -999em; top: -999em;"></iframe>
  33.  
  34.         <div class="form-group">
  35.             <div class="col-sm-offset-4 col-sm-8">
  36.                 <div id="Images" class="">
  37.                     <img src="~/Content/imgs/product/@Model.PicURL" alt="anh san pham" style="width:50px; height:50px;"/>
  38.                 </div>
  39.             </div>
  40.         </div>
  41.        
  42.         <br/>
  43.        
  44.         <div class="col-sm-offset-4 col-sm-8" style="margin-top: 20px;margin-bottom: 20px;">
  45.                 <input type="button" id="submitEdit" value="Cập nhật" class="btn btn-success btn-block" />
  46.             </div>
  47.  
  48. @* doan sciprt hien thi ut button upload *@
  49. <script type="text/javascript">
  50.  
  51.     setInterval('checkUpload()', 300);
  52.  
  53.     $("#submitEdit").click(function () {
  54.         var name = $("#ProductName").val();
  55.        
  56.         if (name.trim() == "") {
  57.             ShowMessage("Vui lòng nhập tên mặt hàng", 3);
  58.             return;
  59.         }
  60.  
  61.         var sPrice = $("#Price").val();
  62.        
  63.         if (sPrice.trim() == "") {
  64.             ShowMessage("Vui lòng nhập giá mặt hàng", 3);
  65.             return;
  66.         }
  67.        
  68.         if (!$.isNumeric(sPrice)) {
  69.             ShowMessage("Vui lòng nhập chữ số cho giá mặt hàng", 3);
  70.             return;
  71.         }
  72.  
  73.         var price = parseInt(sPrice);
  74.  
  75.         if (price <= 0) {
  76.             ShowMessage("Vui lòng nhập giá lớn hơn 0", 3);
  77.             return;
  78.         }
  79.        
  80.  
  81.         $("#editProductForm").submit();
  82.     });
  83.    
  84.     $("#addFile").click(function () {
  85.         $("#imageFile").click();
  86.     });
  87.     $("#imageFile").on('change', function () {
  88.         $('#uploadButton').attr('disabled', false);
  89.     });
  90.  
  91.     function checkUpload() {
  92.         var imageData = document.getElementById('imageFile').value;
  93.         if (imageData.length == 0) {
  94.             $('#uploadButton').attr('disabled', true);
  95.         }
  96.     }
  97.    
  98.  
  99. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement