Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @{
- ViewBag.Title = "Upload";
- Layout = "/Views/Shared/_Layout.cshtml";
- }
- <div class="content read edit">
- <h3>
- <span id="Heading" contenteditable="true">Put heading in here</span>
- <input type="image" src="~/Content/SystemImages/save.png" alt="save" onclick="upd()" />
- <input type="image" src="~/Content/SystemImages/uploadImage.png" alt="upload" onclick="clickRedirFile()" />
- </h3>
- <br />
- <!--<div class="wrap" style="max-width: 808px; min-width: 808px;" >-->
- <div class="wrap">
- <p>
- <div class="imgWrap">
- <img id="contentImg" src="" alt="">
- </div>
- <span id="Content" contenteditable="true">Put some content for news here</span>
- </p>
- </div>
- <div style="display: none;">
- @using (Html.BeginForm("Upload", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
- {
- <input type="file" id="inpFile" name="Upload" />
- <input type="text" id="inpId" name="Id" />
- <input type="text" id="inpHead" name="Heading" />
- <input type="text" id="inpData" name="Content" />
- <input type="text" id="inpFileUpd" name="FileUpdated" value="0" />
- <input type="submit" id="inpSubmit" />
- }
- </div>
- </div>
- <script>
- var head = document.getElementById('Heading');
- var data = document.getElementById('Content');
- function upd() {
- var flag = 0;
- if (head.innerHTML == "") {
- head.innerHTML = "Empty heading";
- flag++;
- }
- if (data.innerHTML == "") {
- data.innerHTML = "Empty paragraph";
- flag++;
- }
- if (flag && confirm('All fields must be filled!\nConfirm auto-fill?'))
- update();
- else
- update();
- }
- function update() {
- document.getElementById('inpHead').value = head.innerHTML;
- document.getElementById('inpData').value = data.innerHTML;
- console.log(document.getElementById('inpHead').value);
- console.log(document.getElementById('inpData').value);
- $('#inpSubmit').click();
- }
- function clickRedirFile() {
- $('#inpFile').click();
- }
- $('#inpFile').change(function () {
- if (this.files && this.files[0]) {
- var reader = new FileReader();
- reader.onload = function (e) {
- $('#contentImg').attr('src', e.target.result);
- }
- reader.readAsDataURL(this.files[0]);
- document.getElementById('inpFileUpd').value = "1";
- }
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement