Click here to Skip to main content
15,890,282 members
Home / Discussions / C#
   

C#

 
AnswerRe: BinaryFormatter - Serialize OutOfMemory Exception Pin
Eddy Vluggen11-Jun-15 12:29
professionalEddy Vluggen11-Jun-15 12:29 
GeneralRe: BinaryFormatter - Serialize OutOfMemory Exception Pin
Kit Fisto23-Jun-15 5:34
Kit Fisto23-Jun-15 5:34 
GeneralRe: BinaryFormatter - Serialize OutOfMemory Exception Pin
Eddy Vluggen23-Jun-15 5:57
professionalEddy Vluggen23-Jun-15 5:57 
QuestionSMTP - Failure sending mail. Pin
Hrishikesh Shivacharan10-Jun-15 23:12
Hrishikesh Shivacharan10-Jun-15 23:12 
AnswerRe: SMTP - Failure sending mail. Pin
OriginalGriff10-Jun-15 23:49
mveOriginalGriff10-Jun-15 23:49 
SuggestionRe: SMTP - Failure sending mail. Pin
Richard MacCutchan11-Jun-15 1:01
mveRichard MacCutchan11-Jun-15 1:01 
AnswerRe: SMTP - Failure sending mail. Pin
Abhipal Singh11-Jun-15 6:23
professionalAbhipal Singh11-Jun-15 6:23 
QuestionHow to write java script for image upload on choose file type not in click function Pin
balajiparamkusam10-Jun-15 4:42
balajiparamkusam10-Jun-15 4:42 
In controller i wrote like this
------------------------------------------
public dynamic multipleimageupload(string image)
{

var aa = image.Split('\\');
var finalPath = aa[2];

var img = WebImage.GetImageFromRequest();
if (finalPath != null)
{
var fileName = finalPath.Replace(" ", "");
var fname = Path.GetFileNameWithoutExtension(fileName);
Regex regex = new Regex("[^a-zA-Z0-9]");
fname = regex.Replace(fname, "");

var fileExtension = Path.GetExtension(fileName);
string timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
var filenamewithtime = fname + "_" + timestamp + fileExtension;

var path = Path.Combine(Server.MapPath("~/Images/Imageupload"), filenamewithtime);
img.Save(path);
var finel = String.Format("/Images/Imageupload/{0}", filenamewithtime);
var userClient = new RestClient(string.Format("{0}/api/UserAccount/POSTImageUpload", MatchedInConfig.MatchedInApiUrl));
var request = new RestRequest(Method.POST);
var sessionResult = Session["UserID"];
request.AddParameter("UserID", sessionResult);
request.AddParameter("Avatar", finel);
var response = userClient.Execute(request);
return null;
}

return null;
}
-------------------------------------
in Api i wrote like this
----------------------------
XML
public MI_PhotoAlbum POSTImageUpload(FacebookRegistrationModel model)
      {
          var userTable = new MI_PhotoAlbum();
         ().Query().Get().Where(a => a.UserId == model.UserID).SingleOrDefault();

          
              userTable.UserId = model.UserID;
              userTable.ImageUrl = model.Avatar;


              _unitOfWork.Repository<MI_PhotoAlbum>().Insert(userTable);
              _unitOfWork.Save();
         
          return userTable;

      }

--------------------------
in partialview
---------------------
XML
<div class="photo-upload-bar">
                  <i class="fa fa-image"></i>Photos<div class="btn btn-primary btn-xs pull-right btn-upload" >Upload <i class="fa fa-plus"></i>
                <input id="choose" type='file' name="fileUpload" onchange="readfile(this);" accept="image/x-png, image/gif, image/jpeg" /></div>

                     @* <label class="control-label col-md-2">Image</label>*@
                      <div class="col-md-10">
                          <img id="image_preview" src="~/Areas/Admin/Images/NoImage/NO_IMAGE.jpg" alt="your image" width="100" height="100" />
                          <input id="RemoveBtnID" style="display: none" type="button" value="Remove" onclick="Removefun()" />
                          @*<input id="choose" type='file' name="fileUpload" onchange="readfile(this);" accept="image/x-png, image/gif, image/jpeg" />*@
                          <span id="para" style="color: red"></span>&nbsp;
                          <span id="SpanImageId" style="color: red;"></span>
                          <br />
                     <span id="SpanimageId" style="color: red;"></span>
                      </div>



C#
<script type="text/javascript">
    jQuery(document).ready(function () {
        ComponentsEditors.init();
    });
    var url = window.URL || window.webkitURL;
    $('#choose').change(function () {
        alert("hii");
    var newInterests = $("#choose").val();
       if (newInterests != "") {
          $.ajax({
                url: "../account/multipleimageupload/?image=" + newInterests,
                type: "Post",
               contentType: 'application/json; charset=utf-8',
                success: function (data) {
                    if (data != 0) {
                        //jq("#tagsTextbox").tokenInput("add", { id: data, name: newInterests });
                        //j1("#customTags").val("");
                        //jq("#customTags").focus();
                    }
                    else {
                        //alert("already exists");
                    }
                },
                error: function () { }
            });
        }
        else {
            //alert(" Interest is required");
        }

        var fileExtension = ['jpeg', 'jpg', 'png', 'gif', 'bmp'];
        if ($.inArray($(this).val().split('.').pop().toLowerCase(), fileExtension) == -1) {
            document.getElementById('para').innerHTML = "<span>Choose Only Image Files</span>";
            Removefun();
            //alert($(this).val());
            document.getElementById('Upload').innerHTML = "<span></span>";
            $('#choose').val('');
            $('#image_preview').attr('src', "/Areas/Admin/Images/NoImage/NO_IMAGE_Thumb.jpg");

            return false;
        }
        else {
            $("#SpanimageId").text("");
            document.getElementById('para').innerHTML = "<span></span>";
            document.getElementById('Upload').innerHTML = "<span></span>";
        }
    });
    function readfile(input) {
        if (input.files && input.files[0]) {
            var reader = new FileReader();
            reader.onload = function (e) {
                $('#image_preview').attr('src', e.target.result);
                var imagesize = input.files[0].size / 2048;
                var ImageSize = imagesize / 2048;
                if (ImageSize > 2) {
                    alert("Image size should be less than 2MB");
                    $('#image_preview').attr('src', "/Areas/Admin/Images/NoImage/NO_IMAGE_Thumb.jpg");
                    $('#RemoveBtnID').hide();
                    $('#choose').show();
                    //$('#choose').val("");
                    return false;
                }
                else {
                    $('#RemoveBtnID').show();
                    //$('#choose').hide();
                    $("#SpanimageId").text("");
                }
            }
            reader.readAsDataURL(input.files[0]);
        }
    }
    function Removefun() {
        $('#image_preview').attr('src', "/Areas/Admin/Images/NoImage/NO_IMAGE.jpg");
        $('#RemoveBtnID').hide();
        $('#choose').show();
        //$('#choose').val("");
    }

</script>

AnswerRe: How to write java script for image upload on choose file type not in click function Pin
CHill6010-Jun-15 4:56
mveCHill6010-Jun-15 4:56 
Question(SOLVED) C# .NET File.Delete() Not Working. Pin
uniflare9-Jun-15 16:28
uniflare9-Jun-15 16:28 
Questionhow to fill textbox with data from access database in c sharp windows application Pin
Being The Sharan Kumar9-Jun-15 7:31
Being The Sharan Kumar9-Jun-15 7:31 
AnswerRe: how to fill textbox with data from access database in c sharp windows application Pin
Richard Deeming9-Jun-15 7:58
mveRichard Deeming9-Jun-15 7:58 
QuestionSystem.Linq.Dynamic.DynamicExpression.ParseLambda issue with Select() command Pin
HUONG Minh-Luong9-Jun-15 4:31
HUONG Minh-Luong9-Jun-15 4:31 
QuestionRe: System.Linq.Dynamic.DynamicExpression.ParseLambda issue with Select() command Pin
Richard Deeming9-Jun-15 5:57
mveRichard Deeming9-Jun-15 5:57 
AnswerRe: System.Linq.Dynamic.DynamicExpression.ParseLambda issue with Select() command Pin
HUONG Minh-Luong9-Jun-15 7:14
HUONG Minh-Luong9-Jun-15 7:14 
QuestionHow to populate a DropDownList in a DataGrid? Pin
Member 85894998-Jun-15 3:51
Member 85894998-Jun-15 3:51 
AnswerRe: How to populate a DropDownList in a DataGrid? Pin
User 418025410-Jul-15 11:55
User 418025410-Jul-15 11:55 
Questionneed help to use telegram api in c# Pin
adalat1237-Jun-15 19:30
adalat1237-Jun-15 19:30 
AnswerRe: need help to use telegram api in c# Pin
Richard MacCutchan7-Jun-15 21:20
mveRichard MacCutchan7-Jun-15 21:20 
QuestionWhat do these c# lines mean???? Pin
Django_Untaken7-Jun-15 5:33
Django_Untaken7-Jun-15 5:33 
AnswerRe: What do these c# lines mean???? Pin
Dave Kreskowiak7-Jun-15 5:42
mveDave Kreskowiak7-Jun-15 5:42 
GeneralRe: What do these c# lines mean???? Pin
OriginalGriff7-Jun-15 6:04
mveOriginalGriff7-Jun-15 6:04 
GeneralRe: What do these c# lines mean???? Pin
Dave Kreskowiak7-Jun-15 6:35
mveDave Kreskowiak7-Jun-15 6:35 
GeneralRe: What do these c# lines mean???? Pin
OriginalGriff7-Jun-15 6:43
mveOriginalGriff7-Jun-15 6:43 
AnswerRe: What do these c# lines mean???? Pin
OriginalGriff7-Jun-15 6:04
mveOriginalGriff7-Jun-15 6:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.