Professional Web Applications Themes

Code Blocks in Custom Control - ASP.NET Building Controls

I have developed a custom control and I want to allow the user to insert code blocks in the .aspx (or .ascx) file to set attributes on the control. For example, I want to allow the user to do this: &lt;pwc:SortColumn HeadingText='<%=GetHeadingText(0)% >'/&gt; &lt;pwc:SortColumn HeadingText='<%=GetHeadingText(1)% >'/&gt; * The GetHeadingText(int colIndex) is a protected method in the codebehind .cs file. When the custom control is pd, the default pr is not seeing this attribute as a code block. It only sees it as a string. Is there any way to use a custom ControlBuilder to force the pr to evaluate this ...

  1. #1

    Default Code Blocks in Custom Control

    I have developed a custom control and I want to allow the
    user to insert code blocks in the .aspx (or .ascx) file to
    set attributes on the control. For example, I want to
    allow the user to do this:

    &lt;pwc:SortColumn HeadingText='<%=GetHeadingText(0)%
    >'/&gt;
    &lt;pwc:SortColumn HeadingText='<%=GetHeadingText(1)%
    >'/&gt;
    * The GetHeadingText(int colIndex) is a protected method
    in the codebehind .cs file.

    When the custom control is pd, the default pr is
    not seeing this attribute as a code block. It only sees
    it as a string. Is there any way to use a custom
    ControlBuilder to force the pr to evaluate this and
    call the code behind method?

    Thanks,
    Darrin Boyd
    [email]subscriptionsmaxiomconsulting.com[/email]

    Darrin Boyd Guest

  2. #2

    Default Code Blocks in Custom Control

    why dont you just have a property that when set, calls the
    GetHeadingText() method from within your control, and say
    populates a private property with the heading text. You
    can then use this result to populate the below code.


    >-----Original Message-----
    >I have developed a custom control and I want to allow the
    >user to insert code blocks in the .aspx (or .ascx) file
    to
    >set attributes on the control. For example, I want to
    >allow the user to do this:
    >
    ><pwc:SortColumn HeadingText='<%=GetHeadingText(0)%
    >>'/>
    ><pwc:SortColumn HeadingText='<%=GetHeadingText(1)%
    >>'/>
    >
    >* The GetHeadingText(int colIndex) is a protected method
    >in the codebehind .cs file.
    >
    >When the custom control is pd, the default pr is
    >not seeing this attribute as a code block. It only sees
    >it as a string. Is there any way to use a custom
    >ControlBuilder to force the pr to evaluate this and
    >call the code behind method?
    >
    >Thanks,
    >Darrin Boyd
    >subscriptionsmaxiomconsulting.com
    >
    >.
    >
    Rory Guest

Similar Threads

  1. Controls that contain code: Code Blocks Not Supported
    By Microsoft in forum ASP.NET Building Controls
    Replies: 1
    Last Post: December 14th, 03:14 PM
  2. Custom control code serialization to class file
    By Dale in forum ASP.NET Building Controls
    Replies: 6
    Last Post: August 2nd, 06:41 AM
  3. Custom control fires event but ignores some code in the code behind file
    By recoil@community.nospam in forum ASP.NET Building Controls
    Replies: 0
    Last Post: March 8th, 05:17 PM
  4. Custom Control that accepts Inline Code
    By JWhitted in forum ASP.NET Building Controls
    Replies: 2
    Last Post: November 8th, 11:10 PM
  5. Custom control issue: Where do I put this code?
    By John Saunders in forum ASP.NET Building Controls
    Replies: 1
    Last Post: August 7th, 02:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139