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

  • SEARCH
  • Home
  • 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 3308056
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:28:40+00:00 2026-05-17T21:28:40+00:00

Let’s assume I have 2 Controllers, TopicsController and PostsController . For each controller, I

  • 0

Let’s assume I have 2 Controllers, TopicsController and PostsController.

For each controller, I have a couple of views (Index & Details).

The Topic (Index) view inherits System.Web.Mvc.ViewPage<IEnumerable<MessageBoard.Models.Topic>>

The Topic (Details) view inherits System.Web.Mvc.ViewPage<MessageBoard.Models.TopicFormViewModel>
I’m using a TopicFormViewModel because I’m sending additional data along with the Model.

The Post (Details) view just inherits System.Web.Mvc.ViewPage<MessageBoard.Models.Post>

Now, I’ve created a partial view (CreatePost.ascx) which is (obviously :p) used to create a new Post. I want to be able to re-use this control on all of the views you see above.

Update
I’ve tried rendering the partial view using <% Html.RenderPartial("New"); %> from my Topics/Index.aspx View, but that results in an exception

The model item passed into the dictionary is of type ‘System.Data.Linq.Table`1[MessageBoard.Models.Topic]’, but this dictionary requires a model item of type ‘MessageBoard.Models.Post’.

Now the problem is that my partial view (CreatePost.ascx) accepts a System.Web.Mvc.ViewUserControl<MessageBoard.Models.Post> and I’m not sure how to pass that from all my views above.

I’m also unsure know how to submit the .ascx values to a certain URL (i.e. /Topics/1/CreatePost), how do I tell the submit button to post to that URL?

Thanks in advance,
Marko

  • 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-05-17T21:28:40+00:00Added an answer on May 17, 2026 at 9:28 pm

    Ciao Marko,

    Now the problem is that my partial
    view (CreatePost.ascx) accepts a
    System.Web.Mvc.ViewUserControl
    and I’m not sure how to pass that from
    all my views above.

    I am not sure I understand what do you mean by “how to pass that from all my views above” but I am sure that you dont have to pass an instance of Post from your views. What is going on is that from your views you will invoke a controller action that creates the Post model object and then bind it to the CreatePost.ascx partial.

    I’m also unsure know how to submit the
    .ascx values to a certain URL (i.e.
    /Topics/1/CreatePost), how do I tell
    the submit button to post to that URL?

    You have two options:

    Inside your CreatePost.ascx partial you are probably using a form.

    <% using (Html.BeginForm("action", "controller", FormMethod.Post, new {} )) { %>
    

    If you use in the way I am showing you can change the first and the second params respectively to the names of the Action and the Controller that would habndle your submit.

    The second option is using jQuery. Simply set an ID for your form and then

    $("#myForm").submit(function(event) {
        //post an ajax request to the server
    });
    

    Hope this helps!

    P.S. To be able to reuse your CreatePost.ascx partial place it inside the shared view folder (where your master page is).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I'm building a data access layer for an application. Typically I have
Let's say you have a class called Customer, which contains the following fields: UserName
Let me try to explain what I need. I have a server that is
Let's say we have a simple function defined in a pseudo language. List<Numbers> SortNumbers(List<Numbers>
Let's say I have a drive such as C:\ , and I want to
Let's say that we have an ARGB color: Color argb = Color.FromARGB(127, 69, 12,
Let's say that I have an arbitrary string like `A man + a plan
Let's say I have a link in a table like: <td class=ms-vb width=100%> <a
Let's say I have a class like this: public class Person { private String
Let's say I have this: public DefaultListModel model = new DefaultListModel(); how do i

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.