Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @*
- hien thi views *@
- <div class="form-group">
- <label class="col-sm-3 col-sm-offset-1 control-label no-padding-right">
- Hình Ảnh</label>
- <div class="col-sm-8">
- <div class="btn-group">
- <input type="hidden" name="PicURL" id="PicURL" readonly="readonly" value="@Model.PicURL"/>
- <a class="btn btn-success btn-small" id="addFile"><i class="icon-plus icon-white"></i></a>
- <input type="button" value="Đăng hình" class="btn btn-info btn-small" id="uploadButton" onclick="UploadImage()" />
- <br />
- </div>
- </div>
- </div>
- @ *Nut hien thi upload *@
- @using (Html.BeginForm("UploadImage", "Product", FormMethod.Post,
- new
- {
- enctype = "multipart/form-data",
- id = "ImgForm",
- name = "ImgForm",
- target = "UploadTarget"
- }))
- {
- <input type="file" id="imageFile" name="imageFile" style="display: none" />
- }
- <iframe id="UploadTarget" name="UploadTarget" onload="UploadImage_Complete();" style="position: absolute; left: -999em; top: -999em;"></iframe>
- <div class="form-group">
- <div class="col-sm-offset-4 col-sm-8">
- <div id="Images" class="">
- <img src="~/Content/imgs/product/@Model.PicURL" alt="anh san pham" style="width:50px; height:50px;"/>
- </div>
- </div>
- </div>
- <br/>
- <div class="col-sm-offset-4 col-sm-8" style="margin-top: 20px;margin-bottom: 20px;">
- <input type="button" id="submitEdit" value="Cập nhật" class="btn btn-success btn-block" />
- </div>
- @* doan sciprt hien thi ut button upload *@
- <script type="text/javascript">
- setInterval('checkUpload()', 300);
- $("#submitEdit").click(function () {
- var name = $("#ProductName").val();
- if (name.trim() == "") {
- ShowMessage("Vui lòng nhập tên mặt hàng", 3);
- return;
- }
- var sPrice = $("#Price").val();
- if (sPrice.trim() == "") {
- ShowMessage("Vui lòng nhập giá mặt hàng", 3);
- return;
- }
- if (!$.isNumeric(sPrice)) {
- ShowMessage("Vui lòng nhập chữ số cho giá mặt hàng", 3);
- return;
- }
- var price = parseInt(sPrice);
- if (price <= 0) {
- ShowMessage("Vui lòng nhập giá lớn hơn 0", 3);
- return;
- }
- $("#editProductForm").submit();
- });
- $("#addFile").click(function () {
- $("#imageFile").click();
- });
- $("#imageFile").on('change', function () {
- $('#uploadButton').attr('disabled', false);
- });
- function checkUpload() {
- var imageData = document.getElementById('imageFile').value;
- if (imageData.length == 0) {
- $('#uploadButton').attr('disabled', true);
- }
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement