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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:52:16+00:00 2026-06-02T04:52:16+00:00

I have some variables defined in partial view called (Partial1.ascx) string value1 = value1;

  • 0

I have some variables defined in partial view called (Partial1.ascx)

  string value1 = "value1";
  string value2 = "value2";
  int id = 7;

Now in ASPX page view, I want to use the above values. In my normal view (aspx page) I have like this:

  <%Html.RenderPartial("Partial1.ascx");%>

  <%=value1 %> becomes <%=value2 %> with his id which is <%=id %>

But the compiler throws error that the value1, value2 and id is not defined.

How to use these variables ?

Have I to define a model (new one) and pass as parameter in RenderPartial function -> <%Html.RenderPartial("Partial1.ascx", NewModel);%> ?

Thank you

  • 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-02T04:52:18+00:00Added an answer on June 2, 2026 at 4:52 am

    You have to define the NewModel in a code block like this on the in the view:

    <% var newModel = new NewModel(); %>
    

    In your partial view you assign the properties in a code block like this:

    <%
      Model.Id = 2;
      Model.Test = "newString";
    %>
    

    Then you can access the properties on the original viewpage like this:

    <p><%=newModel.Test %></p>
    <p><%=newModel.Id %></p>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a javascript object which has some defined variables and attaches some event
I'm taking some information from some variables I have already defined outside this function
I have some public variables that are defined as follows: public class FieldsToMonitor {
I have some 40 variables defined like:-- add_notice_sender = You added %s to the
Some static languages like Java seem to have very special rules for variables defined
I have a large .ps file. There are some variables defined but I am
I have a string that stores some variables that must be executed to produce
The problem is as follows: I have an environment with some variables defined like
At some places I have seen variables declared like this const int &var1; extern
I have some variables inside a template and I don't know where I assigned

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.