0

How can send html img atribute value from view to controller?

<div class="fileupload-new thumbnail" style="width: 200px; height: 150px;">
                @if (Model == null)
                {
                    <img src="http://www.placehold.it/200x150/EFEFEF/AAAAAA&text=no+image" />
                }
                else
                {
                    if (!String.IsNullOrEmpty(Model.Sender.Logofile))
                    {
                    <img src="~/Content/img/Company/LogoFiles/@Model.Sender.Logofile" id="logoimg"/>
                    }
                }
            </div>
            <div class="fileupload-preview fileupload-exists thumbnail" style="max-width: 200px; max-height: 150px; line-height: 20px;"></div>
            <div>
                <span class="btn btn-file"><span class="fileupload-new">Select image</span><span class="fileupload-exists">Change</span>
                    <input type="file" id="LogoFileUp" name="LogoFileUp" size="19" style="opacity: 0;" data-form="uniform" required="required" /></span>
                <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
            </div>

I want to check that Has value got img logoimg or not? How can I do this? Thanks in advance.

2 Answers 2

2

Add an hidden input whose value is your img's src.

2
  • If I don't use any Model property as image, How can I get img href in controller in other way? Commented Jun 7, 2013 at 5:30
  • Request.Form["hidden input name"]
    – Jason Li
    Commented Jun 7, 2013 at 8:40
2

Add an input(hidden) whose has got same value as your img's src .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.