c# - Use of Dynamic Keyword in .Net 3.5 -
I used this code in Visual Studio 2013. Written using V4.5. The problem I have is that I am now declining in Net Work 3.5 and the dynamic keyword is throwing an error because an assembly reference is unavailable. Is there a similar type of 'dynamic' in pure v3.5 or is there a way to get the same result given below for me?
I thought I got my answer, but Var is throwing errors I add. Features or Improve properties
Private Zero CreateControl & lt; T & gt; (String objText, panel pnl, string HTMLTag = "& lt; td>", string applicant ID = "", EventHandler HNSL = null) {pnl.Controls.Add (New Literal Control (HTMLTag)); Dynamic obj = activator.CreateInstance (typeof (t)); Obj.Text = objtext; If (applicant! = String.opti) {obj.Attributes.Add ("ApplicantID", applicant ID); } If (hndl! = Null) {obj.Click + = new event handler (HDL); } Pnl.Controls.Add (obj); Pnl.Controls.Add (New Little Control (HTMLTag.Insert (1, "/");}
Without failing in a few ways and after that there is no 'dynamic' control in pure v3.5, I have instead decided to leave this method completely and instead have written some overload. This way it looks safe at this point; only one works, just a bit more code ...
#region CreateControl () overload /// & lt; summary & gt; / // makes a link button control /// & l Text of this linkbutton control property. & Lt; / param & gt; /// & lt; param name = "pnl"; & lt; param name = "pnl"; & lt; / param & gt; & lt; param name = "objtext" & Gt; This control panel will be attached. & Lt; / param & gt; /// & lt; param name = "hndl" & gt; Event handler which is linked to this linkbutton control. & Param. & Gt; /// & lt; param name = "HTMLTag"> Tags used to control this control. & Lt; / param & gt; Private Zero CreateControl (string objText, panel pnl, EventHandler HNLL , String HTMLTag) {pnl.Controls.Add (New LiteralControl (HTMLTag)); Linkbutton obj = new link button (); Obj.Text = objtext; Obj.Click + = new event heredaler (HDL); Pnl.Controls.Add (obj); Pnl.Controls.Add (New Little Control (HTMLTag.Insert (1, "/");} /// & lt; Summary & gt; /// creates a Label Control /// & lt; / summary & Gt; /// & lt; param name = "objtext" & gt; Previous property of this label control. & Lt; / param & gt; /// & paramount = "pnl" & gt; This control panel & Lt; / param & gt; /// & lt; param name = "HTMLTag" & gt; Tags used to control this control. & Lt; / param & gt; Private zeros CreateControl (string OGT text, panel PNL, string HTMLTag) {pnl.Controls.Add (New Literal Control (HTMLTag)); Label obj = new label (); Obj.Text = objtext; pnl.Controls.Add (obj); Pnl.Controls.Add (New Little Control (HTMLTag.Insert (1, "/")); /// & Lt; summary & gt; /// creates the specified literal control /// & lt; / summary & gt; /// & lt; param name = "ControlText" & gt; HTML text including instructions for creating the desired textual control This will be attached to the literal control panel. & Lt; / param & gt; /// & lt; param name = "pnl" & gt; & Lt; / Param & gt; Private Zero CreateControl (string controltext, panel PNL) {pnl.Controls.Add (new literal control (controltext)); } #endregion
Comments
Post a Comment