Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Custom ExpressionBuilder + ParseControl. No Joy? [modified]

Custom ExpressionBuilder + ParseControl. No Joy? [modified]

Scheduled Pinned Locked Moved ASP.NET
csharphtmldesignsysadminsecurity
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mgkr
    wrote on last edited by
    #1

    Using a custom ExpressionBuilder doesnt seem to work with ParseControl (dynamically adding controls, that are using the custom ExpressionBuilder) Works fine with the build-in Resources ExpressionBuilder though. Anyone have a solution/workaround for this? Or even an explanation for why it doesnt work. Example

    protected void Page\_Load(object sender, EventArgs e) {
      string s = (@"
        <hr />
        1: <asp:Label ID=""Label1"" Text=""<%$ Resources:language, Greeting %>"" runat=""server"" />
        <br />
        2: <asp:Label ID=""Label2"" Text=""<%$ IHLPResource:Greeting %>"" runat=""server"" />
        <hr />
      ");
    
      Control ctrl = ParseControl(s);
      Page.Form.Controls.Add(ctrl);
    }
    

    1: Gets rendered just fine, while 2: fails (no error, the value just doesnt get rendered) ie. the output is:

    1: Hi
    2:

    (2: should say "\\\Output from custom ExpressionBuilder///" - See code below) If I simply add the above to the aspx page, it works fine (ie. my custom ExpressionBuilder is not the cause of failure) -------------------------------------------------------------------------------------------- CODE - For quick copy/paste to test yourself -------------------------------------------------------------------------------------------- DynTest.aspx

    <%@ Page Language="C#" AutoEventWireup="true" Codebehind="DynTest.aspx.cs"
    Inherits="IHLP2007PoC.DynTest" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
    <title>WelcomeLabel Test</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <hr />
    1: <asp:Label ID="Label1" Text="<%$ Resources:language, Greeting %>" runat="server" />
    <br />
    2: <asp:Label ID="Label2" Text="<%$ IHLPResource:Greeting %>" runat="server" />
    <hr />
    </form>
    </body>
    </html>

    DynTest.aspx.cs

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;

    using System.Xml;

    namespace IHLP20

    M 1 Reply Last reply
    0
    • M mgkr

      Using a custom ExpressionBuilder doesnt seem to work with ParseControl (dynamically adding controls, that are using the custom ExpressionBuilder) Works fine with the build-in Resources ExpressionBuilder though. Anyone have a solution/workaround for this? Or even an explanation for why it doesnt work. Example

      protected void Page\_Load(object sender, EventArgs e) {
        string s = (@"
          <hr />
          1: <asp:Label ID=""Label1"" Text=""<%$ Resources:language, Greeting %>"" runat=""server"" />
          <br />
          2: <asp:Label ID=""Label2"" Text=""<%$ IHLPResource:Greeting %>"" runat=""server"" />
          <hr />
        ");
      
        Control ctrl = ParseControl(s);
        Page.Form.Controls.Add(ctrl);
      }
      

      1: Gets rendered just fine, while 2: fails (no error, the value just doesnt get rendered) ie. the output is:

      1: Hi
      2:

      (2: should say "\\\Output from custom ExpressionBuilder///" - See code below) If I simply add the above to the aspx page, it works fine (ie. my custom ExpressionBuilder is not the cause of failure) -------------------------------------------------------------------------------------------- CODE - For quick copy/paste to test yourself -------------------------------------------------------------------------------------------- DynTest.aspx

      <%@ Page Language="C#" AutoEventWireup="true" Codebehind="DynTest.aspx.cs"
      Inherits="IHLP2007PoC.DynTest" %>

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
      Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head id="Head1" runat="server">
      <title>WelcomeLabel Test</title>
      </head>
      <body>
      <form id="form1" runat="server">
      <hr />
      1: <asp:Label ID="Label1" Text="<%$ Resources:language, Greeting %>" runat="server" />
      <br />
      2: <asp:Label ID="Label2" Text="<%$ IHLPResource:Greeting %>" runat="server" />
      <hr />
      </form>
      </body>
      </html>

      DynTest.aspx.cs

      using System;
      using System.Data;
      using System.Configuration;
      using System.Collections;
      using System.Web;
      using System.Web.Security;
      using System.Web.UI;
      using System.Web.UI.WebControls;
      using System.Web.UI.WebControls.WebParts;
      using System.Web.UI.HtmlControls;

      using System.Xml;

      namespace IHLP20

      M Offline
      M Offline
      mgkr
      wrote on last edited by
      #2

      Come now CP... No takers at all?

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups