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 8082053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:57:09+00:00 2026-06-05T16:57:09+00:00

How to render partial view in some specific div without using ajax in asp.net

  • 0

How to render partial view in some specific div without using ajax in asp.net mvc 3???

For example I have a model:

public class TestViewModel
{
    public string FullText
    {
        get
        {
            retrun "Full text";
        }
    }
    public string ShortText
    {
        get
        {
            return "Short text";
        }
    }
}

Main view:

@model TestViewModel
   ...      
    <div id="RenderHere">

    </div>
    @Html.ActionLink("Show short text");
    @Html.ActionLink("Show full text");
   ...

And tow partial views:

ShortTextParial

@model TestViewModel
@Html.LabelFor(m => m.ShortText);
@Model.ShortText;

and FullTextPartial

@model TestViewModel
@Html.LabelFor(m => m.FullText);
@Model.FullText;

How can I render, for example, ShortTextPartial in “RenderHere” div after presing “Show short text” actionlink WITHOUT using ajax??? I have already found such solutions, but they don’t fit me.

P.S. I don’t want to use Ajax because if Java script is disabled on client side the page will not work correctly.

  • 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-05T16:57:10+00:00Added an answer on June 5, 2026 at 4:57 pm

    First of all I have to say I don’t think your design is the best. Please notice that most of the logics, comparisons, and conditions should take place in your Models and Business Logic tier, rather than in Views and Controllers.

    Anyway, If you don’t want to use AJAX, you should either use URL parameters or Session States to pass data between pages. Having said that, I developed it by URL parameters.

    (My development environment is VS2010 SP1, ASP.NET 4, MVC 3)

    First we need to change TextViewModel like this:

    public class TextViewModel
    {
        public string FullText { get { return "Full text"; } }
        public string ShortText { get { return "Short text"; } }
    
        public string ViewMode { get; private set; }
    
        public TextViewModel(string viewMode)
        {
            if (!string.IsNullOrWhiteSpace(viewMode))
                this.ViewMode = viewMode.Trim().ToLower();
        }
    }
    

    Now a little tweak on Controller:

    public class HomeController : Controller
    {
        public ActionResult Index(string id)
        {
            Models.TextViewModel model = new Models.TextViewModel(id);
            return View(model);
        }
    }
    

    and finally our view:

    @model MvcApplication1.Models.TextViewModel
    @{
        ViewBag.Title = "Index";
    }
    <h2>
        Index</h2>
    <div id="RenderHere">
        @if (Model.ViewMode == "short")
        {
            @Html.Partial("ShortTextParial", Model)
        }
        @if (Model.ViewMode == "full")
        {
            @Html.Partial("FullTextPartial", Model)
        }
    </div>
    @Html.ActionLink("Show short text", "Index", new { id = "short" })
    @Html.ActionLink("Show full text", "Index", new { id = "full" })
    

    The application works well in my computer. I’ve uploaded the code here if you need it: http://goo.gl/9v2Ny

    Again I want to say you can come up with a better design which doesn’t need any @if in the View or even in the Controller.

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

Sidebar

Related Questions

in a partial view I have the following: <%Html.RenderAction(MVC.User.GetComments(Model.UserGroupName)); %> can I render a
In my rails view(index.html.erb), i have following structure <div> <%= render :partial => create
I'm using ASP.NET MVC 2. Keeping it simple, I have three payment types: credit
I have an ASP.Net MVC application. I am trying to post data to an
Summary: If you use ASP.NET MVC 2's templates to render a DropDownList, how would
hey there - I'm trying to use asp.net mvc for some things as usual,
ASP.NET MVC 2 I'm trying to write a view whose generic parameter is dynamic
I am using jQuery.load() to render a partial view. This part looks like this:
I'm using the Telerik PanelBar to do some asynchronous loading using a partial view.
In my ASP .NET MVC 3 web application, I am using a lot of

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.