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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:53:50+00:00 2026-06-10T10:53:50+00:00

I have a partial view that I am calling on pages as follows :-

  • 0

I have a partial view that I am calling on pages as follows :-

@Html.Partial("~/Views/Shared/ImageGallery.cshtml", Model)

The code for the actual Jquery of this page is a s follows :-

<script type="text/javascript">
    $(document).ready(function () {

        $('.modal_block').click(function (e) {
            $('#tn_select').empty();
            $('.modal_part').hide();
        });

        $('#modal_link').click(function (e) {
            $('.modal_part').show();
            var context = $('#tn_select').load('/Upload/UploadImage?Page=Article&Action=Edit&id=16', function () {
                initSelect(context);
            });
            e.preventDefault();
            return false;
        });

    });
</script>

Now this works perfectly, however I need to find a way to pass dynamic vars instead of hard coded vars to this :-

Upload/UploadImage?Page=Article&Action=Edit&id=16

In the Model I have all the vars, however I do not know how I can insert them into the Jquery. Any help would be very much appreciated!

———UPDATE———————–

This is the code I am putting into each cshtml that needs the ImageGallery.

</div>
    @Html.HiddenFor(model => model.PageViewModel.Page.PageTitle, new { id = "PageTitle"});
    @Html.HiddenFor(model => model.PageViewModel.Page.PageAction, new { id = "PageAction"});
    @Html.HiddenFor(model => model.ArticleViewModel.Article.ArticleID, new { id = "ArticleID"});
<div>
    @Html.Partial("~/Views/Shared/ImageGallery.cshtml", Model)
</div>

New Javascript in the ImageGallery :-

<script type="text/javascript">

    var pageTitle = $('#PageTitle').val();
    var pageAction = $('#PageAction').val();
    var id = $('#ArticleID').val();
    $(document).ready(function () {
        $('.modal_block').click(function (e) {
            $('#tn_select').empty();
            $('.modal_part').hide();
        });
        $('#modal_link').click(function (e) {
            $('.modal_part').show();
            var context = $('#tn_select').load('/Upload/UploadImage?Page=' + pageTitle + '&Action=' + pageAction + '&id=' + id, function () {
                initSelect(context);
            });
            e.preventDefault();
            return false;
        });
    });

</script>

This works fine now

  • 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-10T10:53:52+00:00Added an answer on June 10, 2026 at 10:53 am

    You can add hidden field to your view and bind data form the model. Then you can easily read this value from jQuery.

    View:

    @Html.HiddenFor(model => model.Id, new { id = "FieldId"});
    

    Script:

    var id= $('#FieldId').val();
    

    Also you can put this hiddens into your partial view. If your partial view is not strongly typed change HiddenFor to Hidden. Your ImageGallery partial view should contain the following div:

    </div>
        @Html.Hidden("PageTitle", Model.PageViewModel.Page.PageTitle);
        @Html.Hidden("PageAction", Model.PageViewModel.Page.PageAction);
        @Html.Hidden("ArticleID", Model.ArticleViewModel.Article.ArticleID);
    <div>
    

    In this case you don’t need to put hiddens to every cshtml that needs the ImageGallery.

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

Sidebar

Related Questions

I have a partial view that is shared between two controllers and I'm trying
I have an ASP.NET MVC Partial View that contains a Html.TextBox that is configured
In my application I want to have one view that holds 2 partial views.
I'm using MVC2 with VS2010 I have a view that has two partial views
if i have created a view model and have a partial form that is
On my main edit view I have 3 partial views that contain child data
I have a view that calls on four different partial views (.ascx) to populate
I have a partial view that I want to basically take care of itself
I have a partial view that I have created called noteEditor. That is rendered
I have a partial view that uses a Telerik MVC Grid, and it has

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.