internal void RenderMarkup(HtmlTextWriter writer) { if (MethodName.Length == 0) { return; } TemplateControl target = TemplateControl; if (target == null) { return; } // get the delegate to the method HttpResponseSubstitutionCallback callback = null; try { callback = GetDelegate(target.GetType(), MethodName); } catch { } if (callback == null) { throw new HttpException( SR.GetString(SR.Substitution_BadMethodName, MethodName)); } // add the substitution to the response Page.Response.WriteSubstitution(callback); }
// Return true if specified evaluator exists on the page with the // correct signature. If it does, return result of invoking it in // evaluatorResult. private bool CheckOnPageEvaluator(MobileCapabilities capabilities, out bool evaluatorResult) { evaluatorResult = false; TemplateControl containingTemplateControl = Owner.ClosestTemplateControl; MethodInfo methodInfo = containingTemplateControl.GetType().GetMethod(_deviceFilter, new Type[] { typeof(MobileCapabilities), typeof(String) } ); if (methodInfo == null || methodInfo.ReturnType != typeof(bool)) { return(false); } else { evaluatorResult = (bool) methodInfo.Invoke(containingTemplateControl, new Object[] { capabilities, _argument } ); return(true); } }
HttpResponseSubstitutionCallback CreateCallback(string method, TemplateControl tc) { try { return(Delegate.CreateDelegate(typeof(HttpResponseSubstitutionCallback), tc.GetType(), method, true, true) as HttpResponseSubstitutionCallback); } catch (Exception ex) { throw new HttpException("Cannot find static method '" + method + "' matching HttpResponseSubstitutionCallback", ex); } }
private void EvalFieldsOnPreRenderComplete(TemplateControl instance) { var type = instance.GetType(); while (!(type == typeof(Page) || type == typeof(UserControl))) { foreach (var field in type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) { EvalKeepInSessionAttributeStore(instance, field); EvalKeepInViewStateAttributeStore(instance, field); } type = type.BaseType; } }
protected override object Evaluate(HttpContext context, Control control) { if ((control == null) || (string.Empty.Equals(PropertyName))) { return(null); } TemplateControl templateControl = control.TemplateControl; Type type = templateControl.GetType(); PropertyInfo property = type.GetProperty(PropertyName); if (property == null) { return(null); } return(property.GetValue(templateControl, null)); }
internal void RenderMarkup(HtmlTextWriter writer) { if (this.MethodName.Length != 0) { TemplateControl templateControl = base.TemplateControl; if (templateControl != null) { HttpResponseSubstitutionCallback callback = null; try { callback = this.GetDelegate(templateControl.GetType(), this.MethodName); } catch { } if (callback == null) { throw new HttpException(System.Web.SR.GetString("Substitution_BadMethodName", new object[] { this.MethodName })); } this.Page.Response.WriteSubstitution(callback); } } }