Click here to Skip to main content
15,041,525 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
it should returning page View instead of pop-up which full of html code.


@model SendAFaxWeb.Models.Home
    Layout = null;

<!DOCTYPE html>

    <meta name="viewport" content="width=device-width" />
        <h2>Fax History List Test</h2>
        <form action="@Url.Action("GetHistory", "Home")" id="form" method="post" enctype="multipart/form-data">
            <table class="table table-condensed">
                @foreach (var item in Model.Documents)
                            <button class="btn btn-xs btn-danger" onclick="d(@item.Name)">
                                <span class="glyphicon glyphicon-trash"></span>


public ActionResult GetHistory()
  //some code here
  return View(history)//list of object

What I have tried:

i have tried to return nothing, but still show popup html. how to put an image in here btw?
Updated 16-Aug-16 3:13am
Karthik_Mahalingam 16-Aug-16 0:28am
what is the exact issue?
you cannot put image here, instead you can host in any open image hosting site and share the url.
wa.war 16-Aug-16 0:32am

take a look the image here.
Karthik_Mahalingam 16-Aug-16 0:34am
post the full cshtml,
you are showing it in alert box
wa.war 16-Aug-16 2:42am
i'm not showing any alert box, like you can see my code above.
Karthik_Mahalingam 16-Aug-16 2:43am
but the sccreenshot shows alertbox
F-ES Sitecore 16-Aug-16 4:24am
The issue is more likely to be the code that calls that view, not the view itself, and you haven't posted that code.
John C Rayan 16-Aug-16 7:20am
Where is the function onclick="d(@item.Name)"

1 solution

I guess, your alert box is an error view (which is also HTML formatted). I would say (after looking in my glass sphere) your Model definition is not correct.

Your model reference:
@model SendAFaxWeb.Models.Home

looks very strange as well. Are you sure, your ViewModel is called "Home"?

And your Controller Action "GetHistory"
public ActionResult GetHistory()
  //some code here
  return View(history)//list of object

what is its result? Your mentioned view? What for? To submit the form again? (... and again, and again, and again...)

I hope, (assuming your ViewModel name is Home) you have:

// for the very first call 
public ActionResult GetHistory()
    SendAFaxWeb.Models.Home history = new SendAFaxWeb.Models.Home();
    //some code to set the model properties here
    history.Documents = GetDocuments(); // or so...
    return View(history)//not a list of objects, but a model containing list of objects

//for the posted data from your form
public ActionResult GetHistory(SendAFaxWeb.Models.Home history)
    //some update actions...

    //after the job is done, redirect to Index
    return RedirectToAction("Index","Home")

If you need to update just a part of the View, it is better to use f. ex. jquery ajax function and update the html content.


The matching html element:

<div id="yourdivname">

The javascript / jquery function (assuming, the input text "myParamTextBox" has your parameter for query:

getUpdatedDivContent = function () {
	var id = $("#myParamTextBox").val();
		url: '@Url.Action("UpdateMyDivContent", "Home")',
		type: 'GET',
		datatype: 'json',
		traditional: true,
		data: { myparameter: id },
		error: function (data) {
		success: function (jsonresponse) {

If you want to have a pretty nice formatted div content, you can return a partial view to the ajax function.

public ActionResult UpdateMyDivContent(string myparameter)
    //if the "Create" static function is defined
    MyVeryNiceViewModel model = MyVeryNiceViewModel.Create(myparameter);
    model.MyProperty1 = "What ever 1";
    model.MyProperty2 = "What ever 2";
    model.MyProperty3 = "What ever 3";

    return PartialView("_yourUpdatedContent", model);

By the way: your form has an id="form". I'm not sure, if this is the happiest idea for an element name. It shouldn't however cause your issue here.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900