jwatney / structuremap.webforms Goto Github PK
View Code? Open in Web Editor NEWStructureMap integration for ASP.NET WebForms.
License: MIT License
StructureMap integration for ASP.NET WebForms.
License: MIT License
Hi,
thanks for sharing your implementation, great :).
While integrating this in our good old Web Forms stuff i am facing a problem.
I assume is has to do with the AspNetControlLifecyclePolicy
public class AspNetControlLifecyclePolicy : IInstancePolicy {
public void Apply(Type pluginType, Instance instance) {
/*
* The lifecycle for each control should always be unique. The default
* namespace for pages and user controls compiled by the ASP.NET
* runtime is 'ASP'.
*/
if((instance.ReturnedType.Namespace ?? "").StartsWith("ASP")) {
instance.SetLifecycleTo(new UniquePerRequestLifecycle());
}
}
}
What was the motivation for the "StartsWith("ASP")"?
If I just want to enable the lifecycle for controls, how about this:
if (typeof(Control).IsAssignableFrom(instance.ReturnedType))
instance.SetLifecycleTo((ILifecycle) new UniquePerRequestLifecycle());
This would work for me.
Background is an exception in an ascx (I do not want to harass you with that) at Render-stage, with happens at an <%= %>
tag. Without the <%= %>
tags there is no exception.
`Error Message: Specified argument was out of the range of valid values.
Parameter name: index
Error Source: System.Web
Exception Stack Trace:
at System.Web.UI.ControlCollection.get_Item(Int32 index)
at ASP.formulare_formulareshopintern_edit_ascx.__Render__control1(HtmlTextWriter __w, Control parameterContainer)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
Best Regards,
Klaus
When I implement this solution on a ASP.NET WebForms page that has a required field validator, I am receiving a runtime error that says the runtime is unable to find a control id that is used by the required field validator attribute ControlToValidate.
When I remove this solution (by commenting it out in the Global.asax code behind) this error goes away. Any ideas why this is occurring and what can be done to resolve it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.