views:

26

answers:

1

I've got an aspx page that renders an ascx page with filtering capabilities. Inside the ascx page, parameters are passed as follows:

<tr>
    <td class="label">Plataforma</td>
    <td class="field lookup"><%= Html.Lookup("s.Site", null, Url, "Sites") %></td>
</tr>
<tr>
    <td class="label">Data</td>
    <td class="field date"><%= Html.TextBox("s.Date", DateTime.Today.ToString("yyyy-MM-dd")) %></td>
</tr>

I need to be able to get those parameters on the main aspx page, because they are needed for an action that is called there. How could I access these parameters?

+2  A: 

Dy default the same Model is available to the page and all partial views on it so you should be able to get this values from the model. If this is not the case you can use the Items collection to pass values in the same request. In the ascx you can add the value to the items collection like this:

<% this.Context.Items.Add("myValue", myValue); %>

In the aspx you can access it like this:

<%= this.Context.Items["myValue"] %>

This method will work but it is not the right way in MVC world. You should perfectly pass all data using the Model and just display it on the views and partial views.

Branislav Abadjimarinov
Thanks, Branislav.
Hallaghan