Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8772735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:06:21+00:00 2026-06-13T18:06:21+00:00

I am making WCF service call using MyViewRequest view fields inside HttpPost ActionHandler. The

  • 0

I am making WCF service call using MyViewRequest view fields inside HttpPost ActionHandler. The goal is to show response using partial view, MyViewResponse

In brief I need to achieve these two items-

  1. Disable load of partial view on first load.
  2. Display Response (along with Request) after service call.

MyViewRequest.cshtml

@using (Html.BeginForm())
{
    @Html.ValidationSummary(false)
    //html code
}
</div>
<div id="dvResponse">
  @Html.Partial("MyViewResponse");
</div>

Partial view: MyViewResponse.cshtml

@model MvcApplication3.Models.MyModel
@{
    ViewBag.Title = "MyViewResponse";
}

<h2>MyView</h2>

@Html.Label(Model.MyName, "My Name")

This was pretty straight forward in Asp.Net using userControl, But stuck up here, How can we achieve this in MVC3.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:06:23+00:00Added an answer on June 13, 2026 at 6:06 pm

    I think the best way is to transfer your data using ViewModels. Let’s assume you want to have an app something like stackoverflow where you have a question and user can post an answer and it will be shown after the post along with the question.

    public class PostViewModel
    {
      public int ID { set;get;}
      public string Text { set;get;}
      public List<PostViewModel> Answers { set;get;}
      public string NewAnswer { set;get;}
    }
    

    in your GET action, you show the question. Get the id from the url and get the Question details from your service/repositary.

    public ActionResult Show(int id)
    {
      var post=new PostViewModel();
      post=yourService.GetQuestionFromID(id);
      post.Answers=yourService.GetAnswersFromQuestionID(id);
      return View(post);  
    }
    

    Assuming yourService.GetQuestionFromID method returns an object of PostViewModel with the propety values filled. The data can be fetched from your database or via a WCF service call. It is up to you. Also yourService.GetAnswersFromQuestionID method returns a list of PostViewModel to represent the Answers for that question. You may put both these into a single method called GetQuestionWithAnswers. I wrote 2 methods to make it more clear.

    Now in your Show view

    @model PostViewModel
    @Html.LabelFor(x=>x.Text);
    @using(Html.Beginform())
    {      
      @Html.HiddenFor(x=>x.ID);     
      @Html.TextBoxFor(x=>x.NewAnswer)
      <input type="submit" />
    }
    <h3>Answers</h3>
    @if(Model.Answers!=null)
    {
      @Html.Partial("Responses",Model.Answers)
    }
    

    And your Partial view will be strongly typed to a collection of PostViewModel

    @model List<PostViewModel>
    @foreach(var item in Model)
    {
      <div> @item.Text </div>
    }
    

    Handling the postback is simple (HttpPost)

    [HttpPost]
    public ActionResult Show(PostViewModel model)
    {
      if(ModelState.IsValid)
      {
        //get your data from model.NewAnswer property and save to your data base 
        //or call WCF method to save it.
        //After saving, Let's redirect to the GET action (PRG pattern)
        return RedirectToAction("Show",new { @id=model.ID});
      } 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a call to a WCF service but I get a CommunicationException on
My WCF service uses callbacks. To be able to call all clients, I'm using
I am consuming a 'third party' WCF service. I am making to call to
I'm trying to access a WCF service, exposed using basicHttpBinding, inside an ASP.NET 2.0
I have a simple ASP.NET site making a call to a WCF service. The
I'm making an AJAX call to a WCF service and when I pass in
http://pastebin.com/FPkZhxAQ Hi, I am making a WCF service/client application. WCF Service is web based.
I'm making a GET request against a WCF web service. My WCF service is
I am creating a WCF WorkflowService and the client is making an async call
I'm making my first WCF Service and I am unsure which route I should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.