VisualStudioFeeds

All Visual Studio blogs in one place

AddThis Social Bookmark Button
The old skool way of passing InitParams in aspx is well documented, adding a: which is accessing the public ‘InitParams’ member in the code-behind file, which is inevitably set up via the ‘Page_Init’ handler. All well and good, but not practical in MVC, so… how to do this? (NB. This is just how I’ve done it, it’s not the only solution) There are a few things to change: 1. The Model I’ve created a SilverlightHostModel, it only has one property in it (at the moment), to hold the InitParams: namespace Webby.Models { public class SilverlightHostModel
{ public string InitParams { get; set; } } } 2. The Controller The controller is going to create the model and pass it to the view.. public ViewResult Ria() { SilverlightHostModel host = new SilverlightHostModel(); host.InitParams = "IpAddress=" + System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; return View(host); } 3. The View The view needs to be strongly-typed to the Model, so we add this to the top of the new view: @model Webby.Models.SilverlightHostModel and where we’re hosting the Silverlight control itself, we change the param to read: (Read whole news on source site)

Search

Subscribe

Enter your email address:

Delivered by FeedBurner

Increase your website traffic with Attracta.com

Contact

Email:
Subject:
Message:
Anti-spam: How many eyes has a typical person?

Follow us on FB

Home : Blog List : xClave.Co.Uk : InitParams in Silverlight – passed via MVC