2007-06-13 Marek Habersack <mhabersack@novell.com>
authorMarek Habersack <grendel@twistedcode.net>
Tue, 12 Jun 2007 22:26:08 +0000 (22:26 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Tue, 12 Jun 2007 22:26:08 +0000 (22:26 -0000)
* TemplateControlCompiler.cs: make sure control has a writable
TemplateControl property prior to assigning values to it.

svn path=/trunk/mcs/; revision=79348

mcs/class/System.Web/System.Web.Compilation/ChangeLog
mcs/class/System.Web/System.Web.Compilation/TemplateControlCompiler.cs

index 077d8add1a69d2078a27bceda8f236162babb092..2b9eb034bd03f30ec0b121d62b2144bf53dc8a18 100644 (file)
@@ -1,3 +1,8 @@
+2007-06-13  Marek Habersack  <mhabersack@novell.com>
+
+       * TemplateControlCompiler.cs: make sure control has a writable
+       TemplateControl property prior to assigning values to it.
+
 2007-06-09  Marek Habersack  <mhabersack@novell.com>
 
        * TemplateControlCompiler.cs: TemplateControl is assigned for
index fb5f57079482cdca9708fc6b040e99f0eff242dc..b3fcf819b4a6a9c1021e11a03c4981a18c214320 100644 (file)
@@ -249,12 +249,21 @@ namespace System.Web.Compilation
 
 #if NET_2_0
                                if (builder.ParentTemplateBuilder is System.Web.UI.WebControls.ContentBuilderInternal) {
-                                       // __ctrl.TemplateControl = this;
-                                       assign = new CodeAssignStatement ();
-                                       assign.Left = new CodePropertyReferenceExpression (ctrlVar, "TemplateControl");;
-                                       assign.Right = thisRef;
-                                       
-                                       method.Statements.Add (assign);
+                                       PropertyInfo pi;
+
+                                       try {
+                                               pi = type.GetProperty ("TemplateControl");
+                                       } catch (Exception) {
+                                               pi = null;
+                                       }
+
+                                       if (pi != null && pi.CanWrite) {
+                                               // __ctrl.TemplateControl = this;
+                                               assign = new CodeAssignStatement ();
+                                               assign.Left = new CodePropertyReferenceExpression (ctrlVar, "TemplateControl");;
+                                               assign.Right = thisRef;
+                                               method.Statements.Add (assign);
+                                       }
                                }
                                
                                // _ctrl.SkinID = $value